Forum How do I...?

How to append content to existing header/footer

rnguyen
Hi,

I am generating a report that has dynamic data in its header and footer. The header and footer are rendered on every page and are drawn from the title page. However, there is a section in the report that adds more data to the same header and footer, but only for that section. For example, if my report has these sections:

1. Title page
2. Table of contents
3. Special section
4. Normal section

Then 1, 2, 4 have the normal header and footer, but 3 has the normal header and footer PLUS extra data.

I know I can set a different header and footer altogether for the special section, using named pages. But this overwrites the data from the normal header and footer. If possible, I would like to not repeat the markup for the normal header and footer.

How can I add data to a header/footer given certain conditions?
pjrm
When you say "not repeat the markup" did you mean "reduce repetition in the stylesheet" ? I don't see why markup needs repetition.

A few possibilities, based on my limited understanding of the situation:
  • CSS "variables" / custom properties.
  • Use a named string for the "normal" content so that the special section can use that named string in addition to its extra content.
  • Use a named string for the possibly extra content, and let it be empty outside of the special section.
  • Use a different named region (@top-left-corner,@top-left,@top-center,...) for the extra content, and make the sizes and alignment such that the two named regions are visually a single region.
  • Accept repetition between rulesets, and just put the two near each other and add a comment. Simplicity is good.
rnguyen
pjrm wrote:
When you say "not repeat the markup" did you mean "reduce repetition in the stylesheet" ? I don't see why markup needs repetition.

For extra context, I'm using AngularJS and the title page and the special section are in different components, and have logic and view code (markup) that is specific to their components. The header and footer code is currently in the title page component only. From my understanding, it would be possible to show extra content for the header and footer if I copy the existing code and paste it with the extra content either in the title page component with some logic so that it knows when to display it, or in the special section component and display the extra content if it is configured to do so (more on this later). In either case, I would be using view code from the title page in the special section component, or logic specific to the special section in the title page component. That it is why I would like to avoid repetition.

pjrm wrote:
CSS "variables" / custom properties.

I'm not sure how these could help me.

pjrm wrote:
Use a named string for the "normal" content so that the special section can use that named string in addition to its extra content.

The "normal" content in the header and footer is probably too complex for a string-set. The content is dynamically generated, and there could be logos, multiple chunks of text, a page counter, all in different regions of the page.

pjrm wrote:
Use a named string for the possibly extra content, and let it be empty outside of the special section.

This is probably a viable option for the extra header content, but I'm not sure if it's possible for the extra content in the footer because it's rendered HTML. For reference, I'm using a rich text editor to generate the content and ng-bind-html to show that content. The extra content for the footer could also possibly be empty.

pjrm wrote:
Use a different named region (@top-left-corner,@top-left,@top-center,...) for the extra content, and make the sizes and alignment such that the two named regions are visually a single region.

A bit hacky, but I will try this.

pjrm wrote:
Accept repetition between rulesets, and just put the two near each other and add a comment. Simplicity is good.

Not desirable for reasons mentioned above, but this is indeed the simplest solution.

Thanks.