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

${esc.hash}${esc.hash} In the container's pre-loop field:

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


${esc.hash}${esc.hash} In the container's Code field:

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