Forum How do I...?


I'm currently doing footers like this css (simplified):

footer {string-set: v_footer content();}


I remember there is some property that allows me to select the *last* <footer> tag on the page for use as that page's footnote, instead of the first. Can you remind me what this property is?

For example, I might have some xml:

<lesson display="no">
<title>Lesson 1</title>
<footer>I don't want this footer to display</footer>

<lesson display="yes">
<title>Alternate Lesson 1</title>
<footer>I want this footer to display</footer>

And I want the correct footer to display. (right now it displays the first one, even though the entire lesson with attribute display="no" is set to display:none, which makes sense still, but I would like to use the other footer...)

Hi Ben,

You can take the last occurrence of a named string simply by adding "last" to the string function, like this:

@page {
    @bottom {
        content: string(v_footer, last);

However, it might be a good idea for you to use a selector such that you only capture the text content of footer elements from lessons that will actually be displayed:

lesson[display="yes"] footer { string-set: v_footer content(); }

This will capture the footer text from only those lessons which are actually displayed in the document, after which you can use first or last with the string function to select which one you want to display in the footer.

Best regards,

Thank you very much Michael, very helpful as always. It works great... however, I couldn't find any of this in the documentation, maybe it would be useful to add it?