Want to hide header in certain passages

Twine Version: Harlowe
I have a passage tagged “header” so that text in that passage appears at the top of every passage in the game. However, there are some passages where I don’t want the header to show up. How can I make it so that select passages don’t display the header?

If you need to conditionally determine at runtime to show the header or not, then one common method used is to wrap the content of that header tagged Passage in a condition check, using one of the “if” family of macros.

eg. The following uses an [(if:)] macro to check the current state of a Boolean $header variable to determine if the header’s content should be shown.

(if: $header)[ ...the contents of the header tagged Passage..]

You would initialise the $header variable to the header’s default state in your project’s startup tagged Passage like so…

(set: $header to true)

…and then use other (set:) macro calls through out the project to toggle the variable’s state between true and false as needed.

On the other hand, if you know at authoring time which Passages the header needs to be suppressed in, then you could assign a known Passage Tag (like noheader) to those passages, and then used a CSS Rule like the following to suppress the displaying of the “header” related HTML element.

eg. A header tagged Passage generates the following HTML element…

<tw-include type="header" name="Name of header tagged Passage">Contents of the header tagged Passage.</tw-include>

…and that element can be suppressed using a CSS rule like…

tw-passage[tags~="noheader"] tw-include[type="header"] {
	display: none;
}
1 Like

Worked, thank you!