Navigation working on most pages.....but not others?
Hello,I recently installed the Cogworks and I have the navigation working properly on most of my pages, however, I noticed today that it is not working properly on others.Here is an example of where the navigation is not correct:http://172.16.30.131:8443/the-saint-leo-experience/student-voices/Snippet of code on the master page is as follows:<umbraco:Macro Alias="[COG]Navigation" StartLevel="2" id="SecondaryNav" runat="server" MenuName="Main" CssId="secondary-navigation"/>This is a test server. The correct navigation should look like this:http://online.saintleo.edu/the-saint-leo-experience/student-voices.aspxThank you in advance.
Ok...hmm, Have you guys double checked that the macro parameters are still placed on the macro? Don't know if they perhaps have vanished during the upgrade. Have a look at the macro definition in the developer section.
Also make sure that all content has been properly published.
Aaah yes that makes it easier to understand...So "Online Community ScreenShots" seems to be a subpage of one of those that should have been listed? Perhaps you need to change the starting level even though that's a bit weird if there has not been made any changes to the positions of the nodes for some reason?
<!--This sets the level that the nav starts at and tells us if we should recurse through child elements--> <xsl:variable name="startDepth" select="/macro/startingLevel" /> <xsl:variable name="recurse" select="/macro/recurse" /> <xsl:variable name="selectBranches" select="/macro/selectBranches"></xsl:variable> <xsl:variable name="maxMenuDepth" select="/macro/maxMenuDepth"></xsl:variable> <xsl:variable name="forceNode" select="/macro/forceNode"></xsl:variable> <xsl:variable name="walkChildren" select="/macro/expandChildren"></xsl:variable> <xsl:variable name="forceHome" select="/macro/forceHome"></xsl:variable> <xsl:variable name="securityTrimming" select="/macro/securityTrimming"></xsl:variable> <!--Alternate page title variable in here-->
<!--Styles for the navigation--> <xsl:variable name="ulBaseClass" select="/macro/ulBaseClass"></xsl:variable> <xsl:variable name="branchClass" select="/macro/branchClass"></xsl:variable> <xsl:variable name="selectedClass" select="/macro/selectedClass"></xsl:variable>
<xsl:if test="$forceHome = 1 and $calculatedMenuDepth = 1"> <!-- Create the class for the li element--> <li> <xsl:variable name="isHomeSelected"> <xsl:choose> <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@level=1]/@id = $currentPage/@id">1</xsl:when> </xsl:choose> </xsl:variable>
<!--for each node in the parent node that is not hidden by Umbraco--> <xsl:for-each select="$parentNode/*[@isDoc][ string(umbracoNaviHide) != '1' and ($securityTrimming != '1' or umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true()) ]">
<!--Set the current node id i.e. the node we have looped to not the current page--> <xsl:variable name="currentNodeID" select="@id" />
<!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes --> <xsl:variable name="isBranch"> <xsl:choose> <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc]">1</xsl:when> </xsl:choose> </xsl:variable>
<!--Is the node selected? i.e. is it the same as the currentPage node--> <xsl:variable name="isSelected"> <xsl:choose> <xsl:when test="$currentPage/@id = $currentNodeID">1</xsl:when> <!-- parent selected --> <xsl:when test="$pseudoCurrentPage/@id = $currentNodeID">1</xsl:when>
<!--set the innerText for the a element--> <xsl:value-of select="./pageTitle/text()"/> <xsl:if test="string(./pageTitle/text()) = ''"> <xsl:value-of select="@nodeName"/> </xsl:if> </a>
<!-- if it's a branch recurse through it's children--> <xsl:if test="((($isBranch = 1 and $recurse = 1) or ($walkChildren = 1 and $pseudoCurrentPage/descendant-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc])) and $maxMenuDepth > $calculatedMenuDepth)"> <xsl:call-template name="nodeIterator"> <xsl:with-param name="parentNode" select="." /> <xsl:with-param name="pseudoCurrentPage" select="$pseudoCurrentPage" /> </xsl:call-template> </xsl:if>
I just meant you should try and change the StartLevel="2" to "1" instead on the macro parameter here
<umbraco:Macro Alias="[COG]Navigation" StartLevel="2" id="SecondaryNav" runat="server" MenuName="Main" CssId="secondary-navigation"/> so it would become
<umbraco:Macro Alias="[COG]Navigation" StartLevel="1" id="SecondaryNav" runat="server" MenuName="Main" CssId="secondary-navigation"/>
Navigation working on most pages.....but not others?
Hello,I recently installed the Cogworks and I have the navigation working properly on most of my pages, however, I noticed today that it is not working properly on others.Here is an example of where the navigation is not correct:http://172.16.30.131:8443/the-saint-leo-experience/student-voices/Snippet of code on the master page is as follows:<umbraco:Macro Alias="[COG]Navigation" StartLevel="2" id="SecondaryNav" runat="server" MenuName="Main" CssId="secondary-navigation"/>This is a test server. The correct navigation should look like this:http://online.saintleo.edu/the-saint-leo-experience/student-voices.aspxThank you in advance.
Hi Jason
What version of Umbraco are you using this package on?
/Jan
Hi Jan,
We are using version 7.1.4 currently with this one.
Thanks,
Jason
Hi Jason
Ok...hmm, Have you guys double checked that the macro parameters are still placed on the macro? Don't know if they perhaps have vanished during the upgrade. Have a look at the macro definition in the developer section.
Also make sure that all content has been properly published.
/Jan
Hi Jan,
I had taken the macro out of the template for testing purposes. I have since put it back.
I was thinking maybe screenshots, so you can see what I do may help. I apologize as I sometimes am not that great at spelling it out.
Here's what I see:
My Umbraco structure for this area (one of several with inaccurate nav):
Nav "should" look like this:
Instead I have this:
Hi Jason
Aaah yes that makes it easier to understand...So "Online Community ScreenShots" seems to be a subpage of one of those that should have been listed? Perhaps you need to change the starting level even though that's a bit weird if there has not been made any changes to the positions of the nodes for some reason?
/Jan
Hi Jan,
Okay so expaining it even further.....
When a user is on the "How Online Learning Works" page, the navigation should be as follows:
-------------------------------------------------------
The Saint Leo Experience
How Online Learning Works
Academic Support & Community
Graduation Day
Student Voices
Career Services
Your Starting Point
---------------------------------------------------------
"The Saint Leo Experience" is the top router page.
The others are all built under that.
Currently, when on the "How Online Learning Works" page, all that shows is:
---------------------------------------------------------
The Saint Leo Experience
Online Community Screen Shots
---------------------------------------------------------
"Online Community Screen Shots" shouldn't be showing in the nav. In the content tree, it is a folder under the "How Online Learning Works".
So you suggest that I change the starting level? If so, what should I change it to?
Thank you so much, Jan. I really appreciate your time and help with this!!
Hi Jason
Try changing it to 1 and see what happens.
/Jan
Hi Jason
Just stumpled upon the official documentation on how to upgrade Umbraco to version 7 - There are quite a few things to be aware of. You can see the document here http://our.umbraco.org/documentation/installation/Upgrading/v7-upgrade
It says that there has been a minor change in the XML structure, which may be the reason why your xslt navigation does not act as expected anymore.
Hope this helps.
/Jan
Hi Jan
Picking up where we left off last week in an effort to get our navigation working correctly.
Using the "How Online Learning Works" page as the test area.
Still only showing the one incorrect navigation entry on the left.
You said to change it to "1" and see what happens.
I am not sure, but I think it may already be set to "1". Can you please see below? Thanks!!
<?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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:param name="currentPage" />
<!--This sets the level that the nav starts at and tells us if we should recurse through child elements-->
<xsl:variable name="startDepth" select="/macro/startingLevel" />
<xsl:variable name="recurse" select="/macro/recurse" />
<xsl:variable name="selectBranches" select="/macro/selectBranches"></xsl:variable>
<xsl:variable name="maxMenuDepth" select="/macro/maxMenuDepth"></xsl:variable>
<xsl:variable name="forceNode" select="/macro/forceNode"></xsl:variable>
<xsl:variable name="walkChildren" select="/macro/expandChildren"></xsl:variable>
<xsl:variable name="forceHome" select="/macro/forceHome"></xsl:variable>
<xsl:variable name="securityTrimming" select="/macro/securityTrimming"></xsl:variable>
<!--Alternate page title variable in here-->
<!--Styles for the navigation-->
<xsl:variable name="ulBaseClass" select="/macro/ulBaseClass"></xsl:variable>
<xsl:variable name="branchClass" select="/macro/branchClass"></xsl:variable>
<xsl:variable name="selectedClass" select="/macro/selectedClass"></xsl:variable>
<xsl:variable name="startLevel">
<xsl:choose>
<xsl:when test="$startDepth >= 0">
<xsl:value-of select="$startDepth"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/@level"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--This calls first iteration of the navigation, sending the first node at the correct depth found in the ancestors of the current page-->
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$forceNode">
<xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById($forceNode)"></xsl:variable>
<xsl:call-template name="nodeIterator">
<xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::*[@isDoc][@level=$startLevel]
[
string(umbracoNaviHide) != '1'
and ($securityTrimming != '1'
or umbraco.library:IsProtected(@id, @path) = false()
or umbraco.library:HasAccess(@id, @path) = true())
]" />
<xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="currentNode" select="$currentPage"></xsl:variable>
<xsl:call-template name="nodeIterator">
<xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::*[@isDoc][@level=$startLevel]
[
string(umbracoNaviHide) != '1'
and ($securityTrimming != '1'
or umbraco.library:IsProtected(@id, @path) = false()
or umbraco.library:HasAccess(@id, @path) = true())
]" />
<xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="nodeIterator">
<xsl:param name="parentNode" />
<xsl:param name="pseudoCurrentPage" />
<!-- do not show info doc node types-->
<xsl:variable name="calculatedMenuDepth" select="($parentNode/@level - $startLevel)+1" />
<xsl:if test="$parentNode/*[@isDoc] or ($calculatedMenuDepth = 1 and $forceHome)">
<ul>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$calculatedMenuDepth = 1">
<xsl:value-of select="concat($ulBaseClass, ' lv', $calculatedMenuDepth)" />
</xsl:when>
<xsl:when test="$calculatedMenuDepth > 1">
<xsl:value-of select="concat('lv', $calculatedMenuDepth)" />
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:if test="$forceHome = 1 and $calculatedMenuDepth = 1">
<!-- Create the class for the li element-->
<li>
<xsl:variable name="isHomeSelected">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@level=1]/@id = $currentPage/@id">1</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="cssClassConstructor">
<xsl:with-param name="isSelected" select="$isHomeSelected" />
<xsl:with-param name="isSelectedBranch" select="0" />
<xsl:with-param name="hasChildren" select="1" />
<xsl:with-param name="selectedClass" select="$selectedClass" />
<xsl:with-param name="branchClass" select="$branchClass" />
</xsl:call-template>
<a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::*[@isDoc][@level=1]/@id)}">
<xsl:call-template name="cssClassConstructor">
<xsl:with-param name="isSelected" select="$isHomeSelected" />
<xsl:with-param name="isSelectedBranch" select="0" />
<xsl:with-param name="hasChildren" select="0" />
<xsl:with-param name="selectedClass" select="$selectedClass" />
<xsl:with-param name="branchClass" select="$branchClass" />
</xsl:call-template>
<!--set the innerText for the a element-->
<xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc][@level=1]/text()"/>
<xsl:if test="string($currentPage/ancestor-or-self::*[@isDoc][@level=1]/text()) = ''">
<xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc][@level=1]/@nodeName"/>
</xsl:if>
</a>
</li>
</xsl:if>
<!--End force home-->
<!--for each node in the parent node that is not hidden by Umbraco-->
<xsl:for-each select="$parentNode/*[@isDoc][
string(umbracoNaviHide) != '1'
and ($securityTrimming != '1'
or umbraco.library:IsProtected(@id, @path) = false()
or umbraco.library:HasAccess(@id, @path) = true())
]">
<!--Set the current node id i.e. the node we have looped to not the current page-->
<xsl:variable name="currentNodeID" select="@id" />
<!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
<xsl:variable name="isBranch">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc]">1</xsl:when>
</xsl:choose>
</xsl:variable>
<!--Is the node selected? i.e. is it the same as the currentPage node-->
<xsl:variable name="isSelected">
<xsl:choose>
<xsl:when test="$currentPage/@id = $currentNodeID">1</xsl:when>
<!-- parent selected -->
<xsl:when test="$pseudoCurrentPage/@id = $currentNodeID">1</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="isSelectedBranch">
<xsl:choose>
<xsl:when test="$isBranch = 1 and $selectBranches = 1">1</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="hasChildren">
<xsl:choose>
<xsl:when test="./*[@isDoc]">1</xsl:when>
</xsl:choose>
</xsl:variable>
<li>
<!-- Create the class attribute for the element-->
<xsl:call-template name="cssClassConstructor">
<xsl:with-param name="isSelected" select="$isSelected" />
<xsl:with-param name="isSelectedBranch" select="$isSelectedBranch" />
<xsl:with-param name="hasChildren" select="$hasChildren" />
<xsl:with-param name="selectedClass" select="$selectedClass" />
<xsl:with-param name="branchClass" select="$branchClass" />
</xsl:call-template>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:call-template name="cssClassConstructor">
<xsl:with-param name="isSelected" select="$isSelected" />
<xsl:with-param name="isSelectedBranch" select="$isSelectedBranch" />
<xsl:with-param name="hasChildren" select="0" />
<xsl:with-param name="selectedClass" select="$selectedClass" />
<xsl:with-param name="branchClass" select="$branchClass" />
</xsl:call-template>
<!--set the innerText for the a element-->
<xsl:value-of select="./pageTitle/text()"/>
<xsl:if test="string(./pageTitle/text()) = ''">
<xsl:value-of select="@nodeName"/>
</xsl:if>
</a>
<!-- if it's a branch recurse through it's children-->
<xsl:if test="((($isBranch = 1 and $recurse = 1) or ($walkChildren = 1 and $pseudoCurrentPage/descendant-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc])) and $maxMenuDepth > $calculatedMenuDepth)">
<xsl:call-template name="nodeIterator">
<xsl:with-param name="parentNode" select="." />
<xsl:with-param name="pseudoCurrentPage" select="$pseudoCurrentPage" />
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<xsl:template name="cssClassConstructor">
<xsl:param name="isSelected"></xsl:param>
<xsl:param name="isSelectedBranch"></xsl:param>
<xsl:param name="hasChildren"></xsl:param>
<xsl:param name="selectedClass"></xsl:param>
<xsl:param name="branchClass"></xsl:param>
<xsl:variable name="class">
<xsl:if test="$isSelected = 1">
<xsl:value-of select="concat($selectedClass,' ')"/>
</xsl:if>
<xsl:if test="$isSelectedBranch = 1">
<xsl:value-of select="concat($branchClass,' ')"/>
</xsl:if>
<xsl:if test="$hasChildren = 1">
<xsl:value-of select="'hasChildren '"/>
</xsl:if>
</xsl:variable>
<xsl:if test="string-length($class) > 0">
<xsl:attribute name="class">
<xsl:value-of select="normalize-space($class)"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Hi Jason
I just meant you should try and change the StartLevel="2" to "1" instead on the macro parameter here
/Jan
is working on a reply...