i would really like to ask for help with 2nd level for Navigation. I really tried everything (to my acknowledge) but i keep coming back to Navi.xsl from Creative Website Wizard. I added template to my site: http://www.simprisk.com/home.aspx and now i wanna have down-drop menu. So, i would like to ask where to add this in this code:
If you create a new property on your document types with the alias of "umbracoNaviHide" (the type is: true/false, let's name it "Hide in navigation?"), then it gets used here. If the checkbox is set to true, then
[string(data [@alias='umbracoNaviHide']) = '1']
So the item should not be shown in the navigation. During the part of the XSLT that you highlighted, it says: get all of the pages under the current page that do NOT have umbracoNaviHide set to true.
I added a class "sub" to <li> for ancestor-or-sefl node. Now, in my page: http://www.simprisk.com/ it's doing great for the first two navigation buttons "domov" and "login" and also for the drop-down menu on "o portalu" button, but the this class applies to "o nas" and "kontaktirajte nas". How can i make thic class work only if there exists subnavigation (drop-down) menu. Should I use some if statment?
I now the basic...but not when it comes to "if" statements. In my site: "http://www.simprisk.com/o-portalu.aspx" I have two sub-pages "Pogoji poslovanja" and "Naročnina" and that's OK. But if i click on "Pogoji poslovanja" i want to show all of the sub-pages that are under parent of "Pogoji poslovanja". So i guess i should use the "if" statement. For now all i have is this:
<!-- set the top level parent node into a variable (you may need to change the @level number depending on the depth of the startNode from the root node) --> <xsl:variable name="startNode" select="$currentPage/ancestor-or-self::node [@level='2']"/>
<!-- display the top level node (there would be a much cleaner way of doing this without a 'for-each' but I cant remember just now) --> <xsl:for-each select="$startNode"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each>
<!-- then loop through the children of the start node --> <xsl:for-each select="$startNode/node"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each>
How to add subNavi
Hello,
i would really like to ask for help with 2nd level for Navigation. I really tried everything (to my acknowledge) but i keep coming back to Navi.xsl from Creative Website Wizard. I added template to my site: http://www.simprisk.com/home.aspx and now i wanna have down-drop menu. So, i would like to ask where to add this in this code:
<xsl:template match="/">
<ul id="nav">
<li class="sub">
<xsl:for-each select="$currentPage/ancestor::root/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</li>
</ul>
</xsl:template>
I would really be thankful for any help!
Thanks, Andraž
Hi Andraz, I think I know what you are trying to do, see if this code works for you...
<?xml version="1.0" encoding="utf-8"?>
<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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="html"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<ul id="nav">
<xsl:for-each select="$currentPage/ancestor::root/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
<xsl:call-template name="SecondLevelNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template name="SecondLevelNodes">
<xsl:param name="parent"/>
<xsl:if test="count($parent/node[string(data [@alias='umbracoNaviHide']) != '1' ]) > 0">
<ul class="second-level">
<xsl:for-each select="$parent/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:template>
</xsl:stylesheet>
Yes, this does the trick.
Could you just explain me what does this code do: [string(data [@alias='umbracoNaviHide']) != '1' ]) > 0
I would really like to thank you for your help!
I wish some day i could pay you back:)
Thx
If you create a new property on your document types with the alias of "umbracoNaviHide" (the type is: true/false, let's name it "Hide in navigation?"), then it gets used here. If the checkbox is set to true, then
So the item should not be shown in the navigation. During the part of the XSLT that you highlighted, it says: get all of the pages under the current page that do NOT have umbracoNaviHide set to true.
Thanks,
for your time, i'ts getting clearer and clearer :)
I would have one more question thought
I added a class "sub" to <li> for ancestor-or-sefl node. Now, in my page: http://www.simprisk.com/ it's doing great for the first two navigation buttons "domov" and "login" and also for the drop-down menu on "o portalu" button, but the this class applies to "o nas" and "kontaktirajte nas". How can i make thic class work only if there exists subnavigation (drop-down) menu. Should I use some if statment?
This is the code:
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li class="sub">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
<xsl:call-template name="SecondLevelNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</li>
</xsl:for-each>
Tnx,
Andraž
Hi Andraz, try this - it has an 'if' statement that checks the child page count and adds the class 'sub' if its > 0.
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<li>
<xsl:if test="count(./node[string(data [@alias='umbracoNaviHide']) != '1' ]) > 0">
<xsl:attribute name="class">sub</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
<xsl:call-template name="SecondLevelNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</li>
</xsl:for-each>
Thanks, if"statment" does the trick
by
I have one more question.
I now the basic...but not when it comes to "if" statements. In my site: "http://www.simprisk.com/o-portalu.aspx" I have two sub-pages "Pogoji poslovanja" and "Naročnina" and that's OK. But if i click on "Pogoji poslovanja" i want to show all of the sub-pages that are under parent of "Pogoji poslovanja". So i guess i should use the "if" statement. For now all i have is this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<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/child::node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
<xsl:for-each select="$currentPage/following-sibling">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Bye,
Andraz
Just doing a
should work..
Andraz - try this...
<!-- set the top level parent node into a variable (you may need to change the @level number depending on the depth of the startNode from the root node) -->
<xsl:variable name="startNode" select="$currentPage/ancestor-or-self::node [@level='2']"/>
<!-- display the top level node (there would be a much cleaner way of doing this without a 'for-each' but I cant remember just now) -->
<xsl:for-each select="$startNode">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
<!-- then loop through the children of the start node -->
<xsl:for-each select="$startNode/node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
is working on a reply...