Linking within a page.
This is an open discussion with 3 replies, filed under General.
Search
try a for-each
<xsl:for-each select="entry"> <a href="{name/@handle}>add the xslvalue-of name</a> </xsl:for-each>
and below add the <a name="{entry/name/@handle}>
But there are no handles for entries. Unless I'm mistaken. If you know please shed some light.
Thank you.
Entries have no handle but you can use as a handle the one of a field output within the very same entry, as jeffleeder suggested.
Assuming your XML is similar to:
<my-section> <entry> <name handle=“something” >Something</name> […] </entry> <entry> <name handle=“something-else” >Something Else</name> […] </entry> </my-section>
you can create a very simple menu at the top of your page:
<xsl:template match="my-section" mode="menu"> <ul> <xsl:apply-templates select="entry" mode="menu"/> </ul> </xsl:template> <xsl:template match="entry" mode="menu"> <li> <a href="#{name/@handle}"> <xsl:value-of select="name"/> </a> </li> </xsl:template>
and when you output the contents of each entry you just need to add an id to their container:
<xsl:template match="my-section"> <xsl:apply-templates select="entry"/> </xsl:template> <xsl:template match="entry"> <div id="{name/@handle}"> […] </div> </xsl:template>
Otherwise you can do something similar using the id of each entry (keeping in mind that, since the id cannot be a mere number, you have to add some text before it):
<xsl:template match="my-section"> <xsl:apply-templates select="entry"/> </xsl:template> <xsl:template match="entry"> <div id="some-text-{@id}"> […] </div> </xsl:template>
Create an account or sign in to comment.
Hello, I'm working on a site that uses Symphony as the CMS. I'm on a page that pulls in "entries". Each of the "entries" use the same "section" code. Hopefully I'm getting my Symphony terminology correct.
Anyway, I need to add anchor links to the top of the page which link to the different "entries" further down the page. Is this possible? I know how to do it outside of Symphony using regular HTML, but I can't add a 'name=""' to the "section" code cause that would apply the name to all the entries. I'm thinking if there is a generic entry handle code that I could use, something like this "{embed-url}"?
Any help would be great.
Thank you!