Needed: a solution for pagebreaks

Hi all

I am willing to donte $25 to the TW development fund if someone can help me out. I have the following:

<$list filter="[tag[foo]]"><$transclude field="text" mode="block"/></$list>

But I would like a way to add a page break <p style="page-break-before: always;">&nbsp;</p> above those tiddlers which are not only tagged foo but also have a pagebreak custom field. This would allow me to define precisely which tiddlers get a page break. That way when I export to static, and users want to print, the page breaks for printing are not before every tiddler in the list, but just before certain ones of my choosing.

Thanks in advance!

Try this out:

<$list filter="[tag[foo]]">
<$list filter="[<currentTiddler>has:field[pagebreak]]">
<p style="page-break-before: always;">&nbsp;</p>
</$list>
<$transclude mode="block"/>
</$list>

Here’s a slightly different approach; here I’ve applied the style to a <div> element wrapping the content rather than an additional paragraph, which means you won’t have any visual break in content in your screen layout.

<$list filter="[tag[foo]]">
<div style={{{ [<currentTiddler>has:field[pagebreak]then[page-break-before: always]] }}}>
<$transclude mode="block"/>
</div>
</$list>

In both cases, I used has:field[pagebreak] so that the page break will also show up if the pagebreak field is extant but empty. You could use has[pagebreak] instead if you didn’t want an empty field to trigger it (or, of course, something like pagebreak[yes] to specify the trigger field value). I’d probably choose has[pagebreak], personally, but it really comes down to how you feel about empty fields.

1 Like

Thanks Emily, that works great! Now it’s time to put my money where my mouth is…

2 Likes