Copied to clipboard

Flag this post as spam?

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


  • Owen Hope 119 posts 140 karma points
    Nov 12, 2010 @ 20:12
    Owen Hope
    0

    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

  • adrianfriend 67 posts 68 karma points
    Nov 12, 2010 @ 20:21
    adrianfriend
    0

    Try the following:

    Set a variable with the level (which will be 1)

    <xsl:variable name="level" select="1"/>

    Then use the following for the for-each loop

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">

    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

  • Owen Hope 119 posts 140 karma points
    Nov 12, 2010 @ 20:30
    Owen Hope
    0

    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>
            <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>

    </xsl:template>
    </xsl:stylesheet>

     

     

  • adrianfriend 67 posts 68 karma points
    Nov 12, 2010 @ 20:38
    adrianfriend
    0

    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.

  • Owen Hope 119 posts 140 karma points
    Nov 12, 2010 @ 20:46
    Owen Hope
    0

    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:

     <ul id="tier1nav">
       <!-- this is where the macro is inserted on Master Template -->
    </ul>
    Thanks,

    Owen
  • adrianfriend 67 posts 68 karma points
    Nov 12, 2010 @ 20:54
    adrianfriend
    0

    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.

     

  • Owen Hope 119 posts 140 karma points
    Nov 12, 2010 @ 20:59
    Owen Hope
    0

    Thanks!

    I restructured my site to look like what you have and the Navigation is now working!

    Thanks for helping a struggling noobie :)

    Owen

Please Sign in or register to post replies

Write your reply to:

Draft