Copied to clipboard

Flag this post as spam?

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


  • Deepali Bhola 23 posts 43 karma points
    Aug 09, 2012 @ 12:16
    Deepali Bhola
    0

    Fotter links through Xslt

    Hello all,

    i have added Generic Properties with name "ShowInFooterLinks" with datatype true/false in my master tamplete.

    so every page which is created with master tamplete has option whether the pagelink is visible in footer links or not.

    now i want to generate Xslt macro which will show me those pages which are checked in "ShowInFooterLinks"

    even if child's parent is not checked it should show me child link in footerLink.

    hope i am clear to my query.

    below code showing me footer links if their parent is checked.

    i am beginner to Xslt so need Help!!

    <xsl:template match="/">
    <div id="sitemap">
    <xsl:call-template name="drawNodes">  
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>  
    </xsl:call-template>
    </div>
    </xsl:template>
    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <div class="top_nav">    
    <ul><xsl:for-each select="$parent/* [@isDoc and string(ShowInFooterLinks) = '1' and @level &lt;= $maxLevelForSitemap]">
    <li>  
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/></a>  
    <xsl:if test="count(./* [@isDoc and string(ShowInFooterLinks) = '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0">   
    <xsl:call-template name="drawNodes">    
    <xsl:with-param name="parent" select="."/>    
    </xsl:call-template>  
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </div>
    </xsl:template>
  • Jordy Vialoux 73 posts 103 karma points
    Aug 10, 2012 @ 02:04
    Jordy Vialoux
    0

    Hi Deepali,

    Here is what you need:

    <xsl:if test="$currentPage/showInFooterLinks = '1'">
        
    </xsl:if>

    Wrap the if statement around your div id "sitemap".

    On default the footer will be hidden so you will need to go to the "properties" tab to select to "show footer links" and it should work. 

    Considering the code you have above is spitting out the nodes you want / need.

    Jordy

  • Jordy Vialoux 73 posts 103 karma points
    Aug 10, 2012 @ 02:07
    Jordy Vialoux
    0

    Also here is an example of the code in action on a site of mine which renders all 2nd level pages under the "about us" section on my site:

    <xsl:variable name="aboutUs" select="umbraco.library:GetXmlNodeById(1054)" />
      <xsl:if test="count($aboutUs/SubPage) &gt; 0">
        <ul>
          <li>
            <span>
              <xsl:value-of select="$aboutUs/@nodeName" />
            </span>
          </li>
          <xsl:for-each select="$aboutUs/SubPage">
            <li>
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName" />
              </a>
            </li>
          </xsl:for-each>
        </ul>
      </xsl:if>

    If you were to wrap the "if" statement in my previous comment around this - this will hide the links on default untill you choose to show them within the umbraco UI.

    Jordy.

  • Deepali Bhola 23 posts 43 karma points
    Aug 10, 2012 @ 09:41
    Deepali Bhola
    0

    Hi Thanks Jordy for Help.

    I get your point, but issue is that if, i need to show only subpage in footer link it is not showing if its parent is not checked.

    and if i checked parent link then it is showing me parent link also in footer which i don't want.

    So

    i want <xsl:for-each ....> loop which will go through from all the page regardless it is parent, child, or child's child.

    then i will do <xsl:if....> to check showInFooterLinks is true or false.


     

Please Sign in or register to post replies

Write your reply to:

Draft