Basic template help required
This is an open discussion with 3 replies, filed under XSLT.
Search
I think you're applying templates too many times. Try a call template to start the links XSLT like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="data"> <xsl:call-template name="link-list"/> </xsl:template> <xsl:template name="link-list"> <h3> <xsl:text>Some links</xsl:text> <xsl:if test="$is-logged-in = 'true'"> <xsl:text> — </xsl:text> <a href="{$root}/symphony/publish/{section/@handle}/new/">Add</a> </xsl:if> </h3> <div class="blah"> <ul> <xsl:apply-templates select="links/entry"/> </ul> </div> </xsl:template> <xsl:template match="entry"> <li> <a href="{link-url}"> <xsl:value-of select="link-name"/> </a> </li> </xsl:template> </xsl:stylesheet>
Thank you very much. That was very helpful.
I think I was mixing up apply-templates and call-template :|
Here's a good example of the difference between the two: http://stackoverflow.com/questions/84422/xslt-performance-call-template-vs-apply-template
Create an account or sign in to comment.
Hi,
I'm just having a mess around with symphony trying things out and I'm stuck :)
I made a new section, data source, utility and page once and everything went smoothly, however I've tried to make another (by exactly the same process as far as I can tell, but with different fields) and something is wrong.
On the ?debug page I have this: http://textsnip.com/74b473/html
Which gets the get-links.xsl here: http://textsnip.com/85b918/html
Which gets stuff from the xml created here: http://textsnip.com/26c4ea/html
But all I get out at the end is:
...Some Links - Add
<div class=blah></div>
...What am I missing? (as you may have guessed I'm not exactly an expert) I realise this is probably a stupid question.
Thanks in advance,
o~