Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Duarte Carreira 47 posts 66 karma points
    Oct 15, 2010 @ 13:15
    Duarte Carreira
    0

    list anchors inside page

    I would like to list all anchors inside a page, to build an index and put it on this page.

    Can this be done with xslt? Does anyone have an example I can follow and adapt?

    Thanks,

    Duarte

  • Carlo Cabrales 58 posts 77 karma points
    Oct 15, 2010 @ 13:35
    Carlo Cabrales
    0

    Not sure if this is what you're looking for but I created an index section for anchors..

    <h3 id="contentsanchor">Contents</h3>
    <p>
    <xsl:for-each select="$currentPage/PolicyCategory">
      <href="#{@nodeName}"><xsl:value-of select="@nodeName"/></a><br />
    </xsl:for-each>
    </p>

  • Carlo Cabrales 58 posts 77 karma points
    Oct 15, 2010 @ 13:36
    Carlo Cabrales
    0

    The actual content of the index I created this..

    <table>
    <xsl:for-each select="$currentPage/PolicyCategory">
        <tr>
          <th>
              <div id="{@nodeName}"><xsl:value-of select="@nodeName"/></div>
          </th>
          <th>&nbsp;</th>
          <th><class="normalfont" href="#contentsanchor">Back to Contents</a></th>
        </tr>
            <xsl:if test="count(./PolicyDocument) &gt; 0">
           <xsl:for-each select="./PolicyDocument">
                    <tr>
        <td>&nbsp;</td>
                       <td><href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></td>
         <td><href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="policyCode"/></a></td>
                    </tr>
                    </xsl:for-each>
            </xsl:if>
    </xsl:for-each>
    </table>
  • Duarte Carreira 47 posts 66 karma points
    Oct 15, 2010 @ 15:47
    Duarte Carreira
    0

    Hi Carlos. Thanks for your examples. I am now aware I did not explain myself correctly...

    What I need is a macro that parses the currentPage, looks for anchors (links with a certain class, or with empty text) and lists them like anchors.

    For instance, if I have this in a page:

    <a name="topic1" class="topic"></a>
    <h2>TopicTitle1<h2>
    Topic text...
    <a name="topic2" class="topic"></a>
    <h2>TopicTitle2</h2>
    Topic text...
    <a name="topic3" class="topic"></a>
    <h2>TopicTitle3</h2>
    Topic text...

    So the macro would collect these and put them in a list:

    <li><a href="#topic1">TopicTitle1</a>
    <li><a href="#topic2">TopicTitle2</a>
    <li><a href="#topic3">TopicTitle3</a>
     So I realize this is a bit more complex than what I wrote initially...

    Duarte

Please Sign in or register to post replies

Write your reply to:

Draft