# Writer: will I ever be able to define conditions using internal variables?

Will it ever be possible to define conditions using internal variables (page, section numbers,...)? e.g. Page == Pages for conditional text in last page footer.

edit retag close merge delete

Sort by » oldest newest most voted

Hi

+1 with @Jim K & @Mike Kaganski

However, it is at least possible:

• To display text on all but the last page. A common example is to display PTO (please turn over). For this just insert a field ▸Document tab▸Type: Page▸Select: Next page▸Format: Text▸Value: type your text. See TextExceptOnLastPage.odt
• To display footer only if the document has more than 1 page. For this insert Hidden Paragraph field with condition page==1 . See ConditionalFooter.odt (add one or more pages to see the footer).

HTH - Regards

more

The Next_page text trick is just what I needed. A good succinct explanation plus an example document too - very much appreciated. Thanks.

( 2018-05-18 09:08:59 +0100 )edit

Instead of fields, create a different page style for the last page. Then enter whatever is needed in the footer.

Headers and footers are the same across all pages with that style. So a condition like currentpage == page is not possible in the footer. Note that page confusingly refers to the total number of pages.

Furthermore, as you apparently know, there is no such variablecurrentpage. According to https://help.libreoffice.org/Writer/D...:

You cannot use internal variables, such as page and chapter numbers, in condition expression.

To me, this seems unlikely to change and would require a great deal of effort to implement. However, you could file an enhancement request and see if anyone is willing to tackle it.

A workaround to determine in the text body whether it is the last page is to increment a variable on each page. I do not see how this would be useful, but here is a sample file: Last Page condition.odt

more

Although you are correct that currently it's impossible, the reasoning behind that ("Headers and footers are the same across all pages with that style. So ... not possible in the footer") is not strictly valid, because if it were, we couldn't have page numbers or chapter titles in headers/footers. Dynamic fields could use dynamically changing stuff in headers; so in theory, it's not impossible.

( 2018-05-16 13:10:17 +0100 )edit

Thanks. Yes, this was the approach I'd tried before posting the question. It works fine provided you don't have paragraph/table content spanning between the last 2 pages, as this method requires a section break to change page_style.

( 2018-05-18 09:31:06 +0100 )edit

You can do quite a lot already. See, for example, @JimK's useful sample for a conditional counter in an earlier Q&A

See also the help information on "Defining Conditions " and "Variables", and the internal links in those pages. It might well be possible to accomplish your scenario, though I haven't attempted that one myself.

more