Copied to clipboard

Flag this post as spam?

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


  • Mehrdad 8 posts 28 karma points
    Feb 16, 2011 @ 17:48
    Mehrdad
    0

    XSLT and side menue

    Hi, I try to write xslt code(Macro) for a side menue that should be developed on our homepage.

    My goal is to have a side menue that list only current page and all subpages, so that by clicking on a node the rest of the node dont disappear. but it list all my nodes and not only current page. this is my xslt code:

    ----

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="self"/>
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="sublevel" select="2"/>

    <xsl:template match="/">
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/*  [@isDoc and string(data [@alias='umbracoNaviHide']) != '1'] ">
     <li>
      <a href="{umbraco.library:NiceUrl(@id)}"> 
                        <xsl:value-of select="@nodeName"/>
      </a>
     </li>
    <xsl:if test="$currentPage/ancestor-or-self::*/@id=current()/@id and count(current()/descendant::* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1']) &gt; 0">
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$sublevel]/* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1'] ">
     <li>*
                      <a href="{umbraco.library:NiceUrl(@id)}">
                      <xsl:value-of  select="@nodeName"/>
                      </a>
             </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>

    ------

    Need help;

    Thanks in advance

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 16, 2011 @ 20:34
    Jan Skovgaard
    0

    Hi Mehrdad

    Try removing the inner <xsl:if> statement like below:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="self"/>
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="sublevel" select="2"/>

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

    Is this what you're after?

    /Jan

  • Mehrdad 8 posts 28 karma points
    Feb 17, 2011 @ 16:17
    Mehrdad
    0

    Hi,

    Thanks for your reply, but it dont work as I want. It only list all the nodes without sub-nodes.

     

    I want something like this if we supouse that we have a page structure like this:

    Page 0

    Page 1

      Sub-page 1

      Sub-page 2

    Page 2

    .............

    Page 3

    .............

    With current page  as Page 1 I need to see only

    Page 1

      Sub-page 1

      Sub-page 2

    if i cklick on page 1.

    Thnaks for any help.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 17, 2011 @ 16:50
    Michael Latouche
    0

    Hi Mehrdad,

    I guess then you do not need to have the intial for-each, so that you only display the current page on top level? So something like this (no guarantee that it is error-proof):

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="self"/>
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="sublevel" select="2"/>

    <xsl:template match="/">
    <ul>
    <li>
      <a href="{umbraco.library:NiceUrl($currentPage/@id)}"> 
                        <xsl:value-of select="$currentPage/@nodeName"/>
      </a>
     </li>
    <xsl:if test="count($currentPage/descendant::* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1']) &gt; 0">
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$sublevel]/* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1'] ">
     <li>*
                      <a href="{umbraco.library:NiceUrl(@id)}">
                      <xsl:value-of  select="@nodeName"/>
                      </a>
             </li>
    </ul>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>

    Cheers,

    Michael

  • Mehrdad 8 posts 28 karma points
    Feb 18, 2011 @ 12:46
    Mehrdad
    0

    Hi Michael,

    It got better but when I click on a sub-page the other sub-page related to same node disappear, like this:

    If we assume we have this page and its sub-page then:

    Page 1

      Sub-page 1

      Sub-page 2

    If I click on the sub-page 2 the sub-page 1 disappear, I want it remains all the time.

    Thanks for your help

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 18, 2011 @ 13:26
    Michael Latouche
    0

    Hi Mehrdad,

    To make sure I get this correctly;: if you click on sub-page 2, what do you want to see? Only sub-page 1, or als Page 1?

    Cheers,

    Michael.

  • Mehrdad 8 posts 28 karma points
    Feb 18, 2011 @ 14:09
    Mehrdad
    0

    Hi, Michael,

    If  I click on sub-page 2 I want to see Page 1 and all sub-pages again and nothing diisappear from the page tree.

     

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 18, 2011 @ 15:06
    Michael Latouche
    0

    Hi Mehrdad,

    I think this should do the work (not tested):

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="self"/>
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="sublevel" select="2"/>

    <xsl:template match="/">
    <xsl:variable name="topLevelNode" select="$currentPage/ancestor-or-self::* [@level=$level]"/>
    <ul>
    <li>
      <a href="{umbraco.library:NiceUrl($topLevelNode/@id)}"> 
                        <xsl:value-of select="$topLevelNode/@nodeName"/>
      </a>
     </li>
    <xsl:if test="count($topLevelNode/descendant::* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1']) &gt; 0">
    <ul>
    <xsl:for-each select="$topLevelNode/descendant::* [@level=$sublevel]/* [@isDoc and string(data [@alias='umbracoNaviHide']) != '1'] ">
     <li>*
                      <a href="{umbraco.library:NiceUrl(@id)}">
                      <xsl:value-of  select="@nodeName"/>
                      </a>
             </li>
    </ul>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>

  • Mehrdad 8 posts 28 karma points
    Feb 24, 2011 @ 12:11
    Mehrdad
    0

    Hi Mike,

    it returns the ancestor of page 1 and all other sub-pages that are not related to the page 1.

     

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft