Back

Dynamic Content Anchors

Description

This snippet creates Anchor Tags and a navigation links for each contentlet in a container.  The idea being that as content is added to the container, it will build a list of links to jump to each contentlet at the top of the page.

Link: http://groups.google.com/group/dotcms/browse_thread/thread/a7fa831e1537bbde?hl=en

Code

## In the container's pre-loop field:

<fieldset class="page_navigation">
    <legend>Page Navigation</legend>
    <ul>
    #foreach($conIdent in $CONTENTLETS)
      #set($conObj = $dotcontent.find($conIdent))
      <li><a href="#con-${conObj.identifier}">$conObj.title</a></li>
    #end
    </ul>
</fieldset>���


## In the container's Code field:

<div class="page_item" id="page-item-$!{ContentIdentifier}">
  <a name="con-$!{ContentIdentifier}"></a>
  <h3>$!{title}</h3>
  $!{body}
</div>