|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
I have a basic site setup - one template, css file, one document, etc. I have created one top level page and two below it, like this: -Content --Home ---About Us ---Contact Us I created an XSLT file and selected the "Navigation Prototype" template. I put the macro onto the template and the menu worked, except the top level item - Home - does not show:hmm: I also tried "Sitemap" but that gave the same results. Actually, I think these 3 menus should all be on the same level? Although if I do that, I don't get any menus at all!? Am I doing something wrong, or not understanding how the "Content" section is organised? Do I need to write some custom XSLT?
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
Gordon Saxby wrote: Actually, I think these 3 menus should all be on the same level? Although if I do that, I don't get any menus at all!?
Oops, no edit function! This is the logical organisation of the menus: -Content --Home --About us --Contact Us At a later stage there will be menus that have sub-menus. The site design isn't set yet, but I expect that the entire menu will need to be visible at all times. I assume that I style the menu items (XSLT / CSS) to display the menu the required way?
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
Can anyone offer advice? I have the following - 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" exclude-result-prefixes="msxml umbraco.library">
<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="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="style">font-weight: bold;</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul>
</xsl:template>
</xsl:stylesheet> I tried changing the variable "level" to 0 (zero) but that didn't work. :(
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Fanatic
Joined: 10/30/2007 Posts: 215 Location: Bellingham
|
Gordon - Here's what we use...notice the 'hard-coding' used to solve the issue but we are using a Dictionary item (atleast) to localize. make sure to create the Dictionary item. Code: ... <xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:comment>start of FullLeftNavigation.xslt</xsl:comment> <xsl:variable name="startNode" select="$currentPage/ancestor-or-self::root/node"/>
<ul> <li> <a href="/default.aspx" title="home"> <xsl:value-of select="umbraco.library:GetDictionaryItem('Home')"/> <xsl:text></xsl:text> </a> </li> <xsl:for-each select="$startNode/node[string(./data [@alias='excludeFromLeftNav']) != '1'][string(./data [@alias='umbracoNaviHide']) != '1']"> <xsl:choose> ...
-Paul motusconnect.com :: level-2 certified :: MVP 2008/2009
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
Thanks Paul - does that mean then, that you have your Home page as the top level, with all other pages / menu items underneath it? Like this (in Umbraco admin) - -Home --About Us --Contact Us
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Fanatic
Joined: 10/30/2007 Posts: 215 Location: Bellingham
|
Exactly. motusconnect.com :: level-2 certified :: MVP 2008/2009
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
Excellent, thank you! I now have a functional (if extremely simple) menu :D
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
I have a menu that uses a style to indicate that a menu option is current / selected. I have managed to get it to work on all pages except the home page! This is the content of my 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" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/> <xsl:variable name="level" select="1"/>
<xsl:template match="/"> <xsl:variable name="startNode" select="$currentPage/ancestor-or-self::root/node"/> <ul> <li> <a href="/default.aspx" title="home"><b> <xsl:value-of select="umbraco.library:GetDictionaryItem('HomePageMenuItemText')"/> </b></a> </li>
<xsl:for-each select="$startNode/node [string(./data [@alias='umbracoNaviHide']) != '1']"> <li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <b><xsl:value-of select="@nodeName"/></b> </a> </li> </xsl:for-each> </ul>
</xsl:template>
</xsl:stylesheet> How can I detect that the Home page is current and therefore set the correct class?
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 156 Location: Surrey, UK
|
OK, I think I've sorted it! I added these lines at line 21 in my code above: Code: <xsl:if test="$startNode/@id = $currentPage/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if>
and it seems to work!?
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
|
Guest |