Copied to clipboard

Flag this post as spam?

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


  • Raheel 62 posts 81 karma points
    Sep 16, 2010 @ 07:14
    Raheel
    0

    Show All Level 1 & 2 Pages

    Hi there,

    I have tried all the options available on Umbraco Template for XSLT / Macro and I am still stuck.

    I want to somehow display All Level 1 and All Level 2 Pages onto my Footer of Master Template - On All Pages.
    There are 3 more templates under Master which are Home Page, Content Pages and One Column Page.

    The issue is if my page is not chosen to have Master as the template then the Macro is not displayed.

    --

    If i create a XSLT with Clean template, can someone please tell me:

    1. What is the code to list all the pages that is on my navigation (From no matter what page you are on)
    So if I am on Home Page or About Us (With a different template) it should still list all the pages on my navigation.

    2. I want to be able to List All Pages sorted by Document Type.
    Example, if there are 20 pages under the Document Type called ContentPages, I want all those pages listed on the footer of all the template and document types.

    Please let me know how I can achieve those two things.
    I want them to be two different XSLT / Macro's


    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 16, 2010 @ 07:37
    Rich Green
    0

    Hi Raheel,

    Try something like this for your first question

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(data [@alias='umbracoNaviHide']) != '1']">
    
    <xsl:if test="./node/@id !=''">
        <h2><xsl:value-of select="@nodeName"/></h2> 
    
        <ul>
            <xsl:for-each select="./node [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>

    This should display all your level 1 nodes with a list of associated level 2 nodes underneath.

    Rich 

  • Raheel 62 posts 81 karma points
    Sep 17, 2010 @ 00:40
    Raheel
    0

    Hi Rich,

    I ended up with a error:

    Error reading XSLT file: \xslt\sitemap.xslt

    is there anything in that code I need to change?

    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 17, 2010 @ 08:47
    Rich Green
    0

    What version of umbraco are you running?

  • Raheel 62 posts 81 karma points
    Sep 17, 2010 @ 08:53
    Raheel
    0

    umbraco v 4.5.2 (Assembly version: 1.0.3891.20719)

  • Rich Green 2246 posts 4008 karma points
    Sep 17, 2010 @ 08:58
    Rich Green
    0

    Ok, my code was for the older schema.

    try this

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc][@level=1]/* [@isDoc][string(umbracoNaviHide) != '1']">
        <xsl:if test="./node/@id !=''">
            <h2><xsl:value-of select="@nodeName"/></h2> 
    
            <ul>
            <xsl:for-each select="./* [@isDoc][string(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>
  • Raheel 62 posts 81 karma points
    Sep 21, 2010 @ 05:33
    Raheel
    0

    Mmmm for some reason I am not getting anywhere on this...

    Here is the screenshot of my Template and Document type structure: http://www.webdesignerpreviews.com.au/aps/tempanddoc.jpg

    Here is the screenshot of my Content Structure: http://www.webdesignerpreviews.com.au/aps/content.jpg

    And here is what I have done:

    On ASPMaster I have got a placeholder...for footerlinks

    On home page I have got a content place holder for footerlinks
    In that place holder I have put the macro of "oneandtwo"

    but I get blanks.... No <ul> </ul> no nothing.

    --

    Here is the XSLT:

     

    <?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:template match="/">


    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc][@level=1]/* [@isDoc][string(umbracoNaviHide) != '1']">
            <xsl:if test="./node/@id !=''">
                    <h2><xsl:value-of select="@nodeName"/></h2

                    <ul>
                    <xsl:for-each select="./* [@isDoc][string(umbracoNaviHide) != '1']">
                            <li>
                                    <href="{umbraco.library:NiceUrl(@id)}">
                                            <xsl:value-of select="@nodeName"/>
                                    </a>
                            </li
                    </xsl:for-each>
                    </ul>
            </xsl:if>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

     

    ---

    Please advice... I  have also tried to put the macro on the ASPMaster itself to see if it shows on all pages.
    I just want to display Level One & Two on all my footer.

     

    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 21, 2010 @ 08:26
    Rich Green
    0

    It might be easier to debug this by placing a new "SiteMap" macro using the "SiteMap" XSLT template, change the max level to 2 and put this in a template somewhere and let us know the output. Essentially you are trying to achieve the same task as  a site map.

    Cheers

    Rich

  • Raheel 62 posts 81 karma points
    Sep 21, 2010 @ 08:51
    Raheel
    0

    The only issue I am having with that is that I am getting the sitemap to be:

    <ul> Level 1 Button Name 1

    <li> level 2 under level 1 </li>
    <li> level 2 under level 1 </li>
    <li> level 2 under level 1 </li>
    <li> level 2 under level 1 </li>
    etc

    </ul>

     

    <ul> Level 1 Button Name 2

    <li> level 2 under level 1 </li>
    <li> level 2 under level 1 </li>
    etc

    </ul>

     

    So now if you have a look at level 1 button name 1, it has more level 2's under it and button 2 has level level 2's under it.
    On footer it looks very annoying as its not aligned right.

    I want it some how to be:

     

     

    <ul> Level 1 

    <li> level 1 </li>
    <li> level 1 </li>
    <li> level 1 </li>
    <li> level 1 </li>
    <li> level 2 </li>
    <li> level 2 </li>
    <li> level 2 </li>
    <li> level 2 </li>

    etc

    </ul>

     

    Meaning all listed under one <ul>

    How do I do that?

     

    Thanks
    Raheel

     

  • Rich Green 2246 posts 4008 karma points
    Sep 21, 2010 @ 08:56
    Rich Green
    0

    Hey Raheel, 

    Getting there. Try this, notice the UL's have moved.

    <?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"/>

    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="2"/>

    <xsl:template match="/">
    <div id="sitemap">
    <ul
      <xsl:call-template name="drawNodes">  
        <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>  
      </xsl:call-template>
    </ul>
    </div>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/> 
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]"
    <li>  
    <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/></a>  
    <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '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>

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

    Rich

  • Raheel 62 posts 81 karma points
    Sep 21, 2010 @ 09:03
    Raheel
    0

    Wow! That worked!!

    Seems like you have a lot of experience with Umbraco up your sleeves... : )

    ---

    If you dont mind me asking...

    That script above solves to get Level 1 & 2 ... 

    Now what If I want to get:

    All the level's below the PAGE NAME X.

     

    So for example:

    Level 1 has: 

    Button 1  |  Button 2  |  Button 3  |  Button 4

     

    Level two:

    Under Button 1 it has:

    Button 1.1  |  Button 1.2  |  Button 1.3

     

    Under Button 2 it has:

    Button 2.1  |  Button 2.2

     

    ...

    So if I wanted to tell on master page saying that:

    Get all level 2 under Button 2... how would that go along?

     

    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 21, 2010 @ 09:30
    Rich Green
    0

    No problem.

    Didn't you have another post with your other question above? If not,post a new thread as it seems you've sorted this one and it might help someone else out in the future.

    Cheers

    Rich

  • Raheel 62 posts 81 karma points
    Sep 22, 2010 @ 01:55
    Raheel
    0

    I am still trying to find out how to mark this post as solved...

Please Sign in or register to post replies

Write your reply to:

Draft