Fairly new to XSLT/Umbraco and having some trouble getting my Navigation to display. Currently nothing is outputted, and having a tough time finding a previous Thread that applies to my problem.
<!-- The fun starts here --> <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each>
Can you make sure that your content is published. Check in a node that you know exists and check in Properties tab and check the Link to document isn't #.
If it is try and republish your site again - Right-hand click Content and select Publish Entire Site.
XSLT Navigation
Hi,
Fairly new to XSLT/Umbraco and having some trouble getting my Navigation to display. Currently nothing is outputted, and having a tough time finding a previous Thread that applies to my problem.
Using Umbraco 4.5.2
My structure is:
| - Content
| - Home
| - Page 1
| - Sub
| - Page 2
| - Page 3
| - Sub
Currently my XSTL reads:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I copied this from another Thread which had a similar structure to mine (so I thought...)
I get no errors and no output which is pretty frustrating to try and debug :(.
Any help with this is much appreciated.
Owen
Try the following:
Set a variable with the level (which will be 1)
Then use the following for the for-each loop
That should get you your first level. You will need to use recursion for the second level if you want that display too.
Hope that helps
Hi,
Thank you for your help but I am still not getting any output from my code.
Here is my full XSLT:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Can you make sure that your content is published. Check in a node that you know exists and check in Properties tab and check the Link to document isn't #.
If it is try and republish your site again - Right-hand click Content and select Publish Entire Site.
I had this the other day with 4.5.2.
Other than that the above could should display.
Hi
I republished the entire site without error, and the Link to document for the home page for instance is: Link to document /home.aspx
When I view source on the Home Page I see the blank line where the Macro has been inserted but none of the code that the XSLT should have generated.
Like this:
Owen
I think it maybe how you have structured your site. There is no root level. My structure would be
Home
- Page 1
- Sub Page
- Page 2
- Sub Page
- Page 3
etc...
Home.aspx would translate to /default.aspx (default page)
If you need to add Home into the UL as an LI add it manually before the for-each.
Thanks!
I restructured my site to look like what you have and the Navigation is now working!
Thanks for helping a struggling noobie :)
Owen
is working on a reply...