<!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation --> <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::root" />
<xsl:template match="/">
<!-- The fun starts here --> <ul> <xsl:for-each select="$siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">active</xsl:attribute> </xsl:if> <xsl:if test="count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) = position()"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">last</xsl:attribute> </xsl:if> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id and count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) = position()"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">last active</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul>
</xsl:template>
</xsl:stylesheet>
But I cant get the menu rendered on the page, please help
Hi Praveen, can you should us your Content Structure?
Or you can try change this
<!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation --> <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::root" /> <xsl:template match="/">
<!-- The fun starts here --> <ul> <xsl:for-each select="$siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">active</xsl:attribute> </xsl:if> <xsl:if test="count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) = position()"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">last</xsl:attribute> </xsl:if> <xsl:if
test="$currentPage/ancestor-or-self::*/@id = current()/@id and
count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) =
position()"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">last active</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul>
to
<!-- Input the documenttype you want here --> <xsl:variablename="level"select="1"/>
<xsl:templatematch="/">
<!-- The fun starts here --> <ul> <xsl:for-eachselect="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:iftest="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attributename="class">active</xsl:attribute> </xsl:if> <xsl:iftest="position()=last()"> <!-- we're under the item - you can do your own styling here --> <xsl:attributename="class">last</xsl:attribute> </xsl:if> <ahref="{umbraco.library:NiceUrl(@id)}"> <xsl:value-ofselect="@nodeName"/> </a> </li> </xsl:for-each> </ul>
<!-- Input the documenttype you want here --> <xsl:variable name="level" select="1"/><xsl:template match="/"> <!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">active</xsl:attribute> </xsl:if>
<xsl:if test="position()=last()"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">last</xsl:attribute> </xsl:if>
Praveen can you send us a screenshot of your content node?....I just check the XSLT and its working, are all the nodes under the same level as your default node such as
There is no need to install any package to be able to view your Top Navigation. Just used the macro you previously created. From your screenshot, i would suggest you to move your innerpages (nodes) starting from Resources to Complicationsfgm like the example below.
One way of doing this since you already created your content is Settings > Choose Homepage Document Type > Click Structure Tab > Check for the InnerPage Document Type.and Save.
Go back to your Content section, right click on one your node and choose Move and Select Home node.
Try with the first node Resources and see if your Top Navigation is showing up and carry one with the other nodes.
Praveen thats weird but you should be able to view your navigation by now. Try one last thing, create another XSLT Files and choose List Sub Pages By Level and insert it in your template.
Give this a try and let me know what is the output. You might need to change your
Hey Praveen i had a quick look to your search and seems to be working fine. Try to add some more fields in your searchFields macros to make your search more efficient.
Praveen under Home Document Type > Click on Strucutre Tab and Checked Related Document Type (Allowed child nodetypes) to be able to create new node under your Home Node.
UMBRACO 4.7 Top Navigation
Hi there,
I have this macro in the Master Template:
<umbraco:Macro Alias="TopNavigation" runat="server"></umbraco:Macro>
and this is the XSLT code
<?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"/>
<!-- Input the documenttype you want here -->
<!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
<!-- Use div elements around this macro combined with css -->
<!-- for styling the navigation -->
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::root" />
<xsl:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:if test="count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) = position()">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id and count($siteRoot/* [@isDoc and string(umbracoNaviHide) != '1']) = position()">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">last active</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
But I cant get the menu rendered on the page, please help
Kind Regards
Praveen
Hi Praveen, can you should us your Content Structure?
Or you can try change this
to
<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:if test="position()=last()">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
//Fuji
Hi Fuli
Many thanks for your help, my menu looks like this, its quite simple
Home | Resources | Contact | Other Links | Other Resources | NZ FGM Programme
I have changed the XSLT as advised, see below, but it still dose not work??
<?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"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="1"/><xsl:template match="/">
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:if test="position()=last()">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/> </a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Praveen can you send us a screenshot of your content node?....I just check the XSLT and its working, are all the nodes under the same level as your default node such as
Content
- Default(home)
-- Resources
--- Contact
--- Other Links
--- Other Resources
--- NZ FGM Programme
//fuji
Hi Fujji
Many thanks for your help :)
Please find the content screen shot, the nodes which are highlighted are ment to be hidden from the top menu "Hide From Menus"
after installing 4.7 I have not installed any packages on top of this, do I need to install something for the Top Navigation to work?
Hi Praveen,
There is no need to install any package to be able to view your Top Navigation. Just used the macro you previously created. From your screenshot, i would suggest you to move your innerpages (nodes) starting from Resources to Complicationsfgm like the example below.
One way of doing this since you already created your content is Settings > Choose Homepage Document Type > Click Structure Tab > Check for the InnerPage Document Type.and Save.
Go back to your Content section, right click on one your node and choose Move and Select Home node.
Try with the first node Resources and see if your Top Navigation is showing up and carry one with the other nodes.
//fuji
Hi Fuji many thanks I did what you recommended but it still dose not help
Setting Screen Shot
Content Tab
Praveen thats weird but you should be able to view your navigation by now. Try one last thing, create another XSLT Files and choose List Sub Pages By Level and insert it in your template.
Give this a try and let me know what is the output. You might need to change your
to
Let me know if you are getting any output
HI Fuji
I have set the UseLegacyXmlSchema to FALSE is this the cause of the problem
I am not able to get the search work as well, I have used the XSLTsearch 3.0 package?
if you give me your email I can send the password to the site you can log in and see what the problem is.
Thanks
Praveen
I would suggest you set it back to true!! Here is my email drop me a mail [email protected]
//fuji
HI Fuji
I sent you the mail, lookforward to hear from you
Many thanks for your help
Regards
Praveen
Ill have a look at it.
Hey Praveen i had a quick look to your search and seems to be working fine. Try to add some more fields in your searchFields macros to make your search more efficient.
//fuji
Praveen under Home Document Type > Click on Strucutre Tab and Checked Related Document Type (Allowed child nodetypes) to be able to create new node under your Home Node.
//fuji
HI Fuji
Many thanks for your help, it did work!
Regards
Praveen
great if you got it working.
//fuji
is working on a reply...