Next / Previous / Contents / TCC Help System / NM Tech homepage

6.13. Conditional expansion: ifTarget

Use this element to enclose content that should be generated only in specific situations. For example, you might want to generate a label like “Next: …” followed by a link to the next page, but only if there is a next page.

Use the context attribute to specify in which cases you want that content to be generated. For example, to generate a section only for pages that have a next page, you can wrap the section in something like this:

<ifTarget context="next">
  conditional content
</ifTarget>

Here is the schema for the element in general:

template.rnc
ifTarget = element ifTarget
{ attribute context
  { "next" | "no-next" | "prev" | "no-prev" | "see" | "no-see" |
    "up"   | "no-up"
  }
  any
}

The any keyword allows any content inside the ifTarget element.

Here are the possible values of the context attribute, and their meanings.

next Expanded only if there is a next page.
no-next Expanded only if there is no next page.
prev Expanded only if there is a previous page.
no-prev Expanded only if there is no previous page.
see Expanded only if there is at least one see-also link (whether it is the parent page or one or more designated see-also topics).
no-see Expanded only if there are no see-also links.
up Expanded only if there is a parent page.
no-up Expanded only if this is the root page, with no parent.

Here is an example. This piece of a template generates a boldfaced “Next:”, followed by a link to the next page, but only on pages that have a next page. We assume that the tp: namespace qualifier refers to elements in the template (template.rnc) schema.

  <tp:ifTarget context="next">
    <b>Next: </b>
    <tp:nextURL>
      <tp:nextTitle/>
    </tp:nextURL>
  </tp:ifTarget>