Page 1 of 1

Headers and footers

Posted: Tue Oct 22, 2019 3:28 pm
by Manohar_1024
Hello,
I want to have different footer for each topic.
For Example:
Topic 1: in footer "indent no: 3ABC 411490"

Topic 2: in footer "indent no: 3ABC 411497"

Topic 3: in footer "indent no: 3ABC 411459"

I am using Dita with css Transformation. Can you please help me in achieving this.

Thank you,
Manohar.

Re: Headers and footers

Posted: Wed Oct 23, 2019 5:35 pm
by Costin
It is possible to dynamically change the header depending on the content in a topic.
The following example assumes that the data to be presented in the header is located in the metadata section of each topic. One way is to specify it in the DITA map is by using the topicmeta element for the topicref topic reference:

Code: Select all

...
 <topicref href="topics/installing.dita">
    <topicmeta>
      <data name="header-data" value="ID778-3211"/>
    </topicmeta>
...
In the above example, there is set of key value pairs with the name header-data. This information is automatically copied into the content in the merged map file, like this:

Code: Select all

<topic ... >
    <title class="- topic/title ">Installing</title>
    <shortdesc class="- topic/shortdesc ">You install components to make them available for your
      solution.</shortdesc>
    <prolog class="- topic/prolog ">
      ...
      <data class="- topic/data " name="header-data" value="ID778-3211"/>
      ...
This information can be extracted from the CSS:

Code: Select all

/* Define the string set variable that contains the text extracted from the data element */
*[class ~= "topic/topic"] *[class ~= "topic/data"][name="header-data"] {
  string-set: hdrstr attr(value);
}

/* Using the value='none' stops applying the image. */
*[class ~= "topic/topic"] *[class ~= "topic/data"][name="header-data"][value="none"] {
  string-set: hdrstr "";
}

/* Use the string set variable in one of the page margin boxes. */
@page chapter {  
  @top-left-corner {
    content: string(hdrstr);
  }
}
The string set is applied to all pages that follow the data element, until another data element changes it:

Code: Select all

<topicref href="topics/installing.dita">
    <topicmeta>
      <data name="header-data" value="ID778-3211"/>
    </topicmeta>
 </topicref>
 <topicref href="..."> <!-- Uses the same value -->
 <topicref href="..."> <!-- Uses the same value -->
 <topicref href="..."> <!-- Uses the same value -->
 <topicref href="topics/change.dita">
    <topicmeta>
      <data name="header-data" value="ID990-3200"/>
    </topicmeta>
 </topicref>
 <topicref href="..."> <!-- The string set is changed now -->
 <topicref href="..."> <!-- The string set is changed now -->
 <topicref href="..."> <!-- The string set is changed now -->
Hope this helps!
Costin