Copied to clipboard

Flag this post as spam?

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


  • Lars 66 posts 136 karma points
    Jun 20, 2011 @ 12:20
    Lars
    0

    Getting XSLT links at the same level as "start"

    Hello. I am brand new to XSLT.

    I have a homepage with the following structure

    - start
    - page 1
        - subpage 1
        - supbage 2
    - page 2
    - page 3

    I take the XSLT file topNavigation.xslt from the libary and make a macro. I insert the macro but it only works for page 1 showing suppage 1 and suppage 2.

    How can I make it show pages at the same level as my startpage.

    My inserted XSLT is below looks like this and it is standard Umbraco template XSLT.

    Any help will be appreciated.

    Thanks in advance and regards

    Lars

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

  • Rich Green 2246 posts 4008 karma points
    Jun 20, 2011 @ 12:45
    Rich Green
    0

    Hey Lars,

    In my opinion you should (if you're not too far down the road) change the structure of your site to:

    --- start (home)

    --------- page 1

    --------------- subpage 1

    --------------- supbage 2

    --------- page 2

    --------- page 3

    This will mean that all the default scripts will run much nicer, the way your structure is set up at the moment will cause you no end of problems (in my opinion).

    Rich

     

  • Lars 66 posts 136 karma points
    Jun 20, 2011 @ 13:03
    Lars
    0

    Hi Rich

    Thank you for your quick answer.

    I am shure that making another level will make a solution but it must be possible to include the "start" page in a XSLT generated menu. I would still like to know how!

    Lars

  • Rich Green 2246 posts 4008 karma points
    Jun 20, 2011 @ 13:05
    Rich Green
    0

    Change the variable to 0 I think.

    Rich

  • Lars 66 posts 136 karma points
    Jun 20, 2011 @ 14:55
    Lars
    0

    YES tbe code below works. It helps to look at what other and wiser people have done, so I fount the solution at http://our.umbraco.org/forum/using/ui-questions/16583-Need-help-with-sub-navigation-XSLT

    But thank you anyway Rich for your help!

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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="rootNode" select="$currentPage/ancestor-or-self::*[@level=1]" />
    <xsl:template match="/">
        <ul id="subMenu">
          <li>
            <a href="{umbraco.library:NiceUrl($rootNode/@id)}">
                <xsl:value-of select="$currentPage/ancestor-or-self::*[@level = '1']/@nodeName"/>
            </a>
          </li>
            <xsl:apply-templates select="$rootNode/*[@isDoc and string(umbracoNaviHide) != '1']"/>
     
        </ul>
    </xsl:template>  

    <xsl:template match="*[@isDoc and string(umbracoNaviHide) != '2']">
        <xsl:variable name="id" select="id" />
        <li class="subNiveau">
            <xsl:attribute name="class">subNiveau<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> current</xsl:if></xsl:attribute>
            <a href="{umbraco.library:NiceUrl(./@id)}">
              <xsl:value-of select="@nodeName" />
            </a>
        </li>
        <xsl:if test="count(./*[@isDoc and string(umbracoNaviHide) != '1']) &gt; 0 and count(descendant-or-self::*[@id = $currentPage/@id]) &gt; 0">
            <li class="nav">
                <ul>        
                  <xsl:apply-templates select="./*[@isDoc and string(umbracoNaviHide) != '1']" />        
              </ul>
            </li>  
        </xsl:if>
    </xsl:template>
     

    </xsl:stylesheet>

  • Lars 66 posts 136 karma points
    Sep 13, 2011 @ 08:10
    Lars
    0

    Hey. Can anyone explain me how to start a new topic in the Umbraco forum? It should be quite straightforward but I am lost. I have an Umbraco forum profile already. Regards, Lars

  • Rich Green 2246 posts 4008 karma points
    Sep 13, 2011 @ 08:19
    Rich Green
    0

    Hey Lars,

    First you select the category on this page

    Then you get to this page where you can see the 'Create a new topic' button

     

    Hope this helps.

    Rich

  • Lars 66 posts 136 karma points
    Sep 15, 2011 @ 13:58
    Lars
    0

    Hey Rich

    Thank you very much and yes, it helped me. Now I just need to learn the rest of Umbraco :-).

    Lars

Please Sign in or register to post replies

Write your reply to:

Draft