Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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"> <a href="#{@nodeName}"><xsl:value-of select="@nodeName"/></a><br /></xsl:for-each></p>
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> </th> <th><a class="normalfont" href="#contentsanchor">Back to Contents</a></th> </tr> <xsl:if test="count(./PolicyDocument) > 0"> <xsl:for-each select="./PolicyDocument"> <tr> <td> </td> <td><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></td> <td><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="policyCode"/></a></td> </tr> </xsl:for-each> </xsl:if></xsl:for-each></table>
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...
<li><a href="#topic1">TopicTitle1</a> <li><a href="#topic2">TopicTitle2</a> <li><a href="#topic3">TopicTitle3</a>
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
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
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">
<a href="#{@nodeName}"><xsl:value-of select="@nodeName"/></a><br />
</xsl:for-each>
</p>
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> </th>
<th><a class="normalfont" href="#contentsanchor">Back to Contents</a></th>
</tr>
<xsl:if test="count(./PolicyDocument) > 0">
<xsl:for-each select="./PolicyDocument">
<tr>
<td> </td>
<td><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></td>
<td><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="policyCode"/></a></td>
</tr>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</table>
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>
So I realize this is a bit more complex than what I wrote initially...<li><a href="#topic2">TopicTitle2</a>
<li><a href="#topic3">TopicTitle3</a>
Duarte
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.