Help with site main menu, referencing directly to a node instead of currentPage
The site im working on, has a main menu at the top a "mega menu" as the designers here call it. Its on every page and ever present.
It shows the main section of the site, and when the cursor hovers over it shows a dropdown menu that contains some content from that section, like newest articles, links sub-sections etc.
I can get content from it, so its wired up and working. Except for one thing, and that is the xpath (i guess).
Right now, it looks for the descendants of currentPage, so if you are on say Section 1, you cant get any content from the menu that links to Section 2 and vice versa. And when you get further down some content vanishes, obviously because its looking for descendants.
I know that currentpage is wrong, but that was the only solution i know if right now. I hope you understand my problem, if there is any questions please ask.
I would create a new XSLT file and base it on the 'SiteMap' template, have a look at how this works.
You're right in that currentPage isn't too helpful in this case (apart from highlighting the item of nav you're on).
What you need to do is always base the navigation from a fixed node (in this case the homepage / main node) or the root of the site, in effect the mark up should stay the same regardless of where you are in the site.
Thank you for your reply, yeah, thats exactly what i want it to do. I took at look at the default sitemap, either i dont know enough to understand it, or it isnt really what i need, sort of.
Its not just navigation, it also displays content.
With the exception that mine has macros that displays latest articles in that section etc. And it has to stay the same regardless of page a user is viewing.
I will keep fiddling with the default site map, but for good measure, how do i select the main node? Or is there another clever method?
Thank you! So i did a combination of both of your solutions, and it works greatly, except for one error.
Before, when i used currentPage, it obviously only showed items for that section i was looking at, but when i was at the root main page, it only showed ONE item on the list, when i looked at that particular section, it showed all items on the list as it should. Which was odd but i didnt think much about since i knew it didnt work correctly.
But now i used your advice, and it does show the correct items regardless what page im looking at BUT it only shows ONE item. Very odd indeed.
It's hard to completely say what's wrong, but the only thing (in the code above) that would limit the output (excluding the $maxItems parameter which I assume is OK) would be if you're not matching the right DocumentTypes - it seems you're including plenty more than you're excluding, so you should maybe flip the logic, to easier see if you're missing some:
<!-- Template for DocumentTypes to display -->
<xsl:template match="*[@isDoc]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<!-- Take first image (if any) -->
<xsl:apply-templates select="outputPictures[1]" />
<!-- Article heading and teaser text-->
<h5><xsl:value-of select="articleHeading"/></h5>
<!-- <p class="teaser"><xsl:value-of select="umbraco.library:TruncateString(artikel-Teasertekst,40,'...')"/></p> -->
</a>
</li>
</xsl:template>
<!-- Template for all excluded DocumentTypes -->
<xsl:template match="Settings | SecretData | etc" priority="1">
<!-- Suppress output... -->
</xsl:template>
(Note that you'll also need to flip the priority attribute to "1")
I appreciate your reply, as my macro didnt originally work i let it be for the time being as i worked on other bits, now that you replied i returned to it, only to see that it doesnt work at all now.
As in it doesnt display any items on the list at all, before or after your fix, so that isnt related i think. The macro is wired up, and it can display hardcoded text from the xslt (as a test to see if it worked at all). Really, really wierd...
EDIT
Ok i tried changing the test against maxItems to "greater than" instead of "less than" it it spat out EVERY document from that section. So there is a connection of sorts, but i still need to figure out whats wrong. Strange indeed...
Help with site main menu, referencing directly to a node instead of currentPage
The site im working on, has a main menu at the top a "mega menu" as the designers here call it. Its on every page and ever present.
It shows the main section of the site, and when the cursor hovers over it shows a dropdown menu that contains some content from that section, like newest articles, links sub-sections etc.
-Main
---Section 1
-----blabla
-----blabla
---Section 2
-----blabla
I can get content from it, so its wired up and working. Except for one thing, and that is the xpath (i guess).
Right now, it looks for the descendants of currentPage, so if you are on say Section 1, you cant get any content from the menu that links to Section 2 and vice versa.
And when you get further down some content vanishes, obviously because its looking for descendants.
I know that currentpage is wrong, but that was the only solution i know if right now. I hope you understand my problem, if there is any questions please ask.
Hey,
I would create a new XSLT file and base it on the 'SiteMap' template, have a look at how this works.
You're right in that currentPage isn't too helpful in this case (apart from highlighting the item of nav you're on).
What you need to do is always base the navigation from a fixed node (in this case the homepage / main node) or the root of the site, in effect the mark up should stay the same regardless of where you are in the site.
Hope that helps.
Rich
Thank you for your reply, yeah, thats exactly what i want it to do. I took at look at the default sitemap, either i dont know enough to understand it, or it isnt really what i need, sort of.
Its not just navigation, it also displays content.
The menu is like these
http://designm.ag/inspiration/mega-menus/
With the exception that mine has macros that displays latest articles in that section etc. And it has to stay the same regardless of page a user is viewing.
I will keep fiddling with the default site map, but for good measure, how do i select the main node? Or is there another clever method?
Hi,
Maybe have a look at the XSLT template that is called 'List Sub pages from a changeable source' then change the following line
umbraco.library:GetXmlNodeById($source)
to something like
umbraco.library:GetXmlNodeById(1129)
(change 1129 for whatever your home node is) see what this renders, and then have a play with the XSLT to also list the 3rd level.
(You don't really need to hard code the home node, but it'll get you started.)
Rich
Hi Frederik,
My default XSLT setup always creates a siteRoot variable just after the currentPage:
I then use that variable to select whatever is needed when it's not really related to currentPage, e.g.:
/Chriztian
Thank you! So i did a combination of both of your solutions, and it works greatly, except for one error.
Before, when i used currentPage, it obviously only showed items for that section i was looking at, but when i was at the root main page, it only showed ONE item on the list, when i looked at that particular section, it showed all items on the list as it should. Which was odd but i didnt think much about since i knew it didnt work correctly.
But now i used your advice, and it does show the correct items regardless what page im looking at BUT it only shows ONE item. Very odd indeed.
Sorry for bumping, but i really need some advice.
Hi Frederik,
It's hard to completely say what's wrong, but the only thing (in the code above) that would limit the output (excluding the $maxItems parameter which I assume is OK) would be if you're not matching the right DocumentTypes - it seems you're including plenty more than you're excluding, so you should maybe flip the logic, to easier see if you're missing some:
(Note that you'll also need to flip the priority attribute to "1")
/Chriztian
I appreciate your reply, as my macro didnt originally work i let it be for the time being as i worked on other bits, now that you replied i returned to it, only to see that it doesnt work at all now.
As in it doesnt display any items on the list at all, before or after your fix, so that isnt related i think. The macro is wired up, and it can display hardcoded text from the xslt (as a test to see if it worked at all). Really, really wierd...
EDIT
Ok i tried changing the test against maxItems to "greater than" instead of "less than" it it spat out EVERY document from that section. So there is a connection of sorts, but i still need to figure out whats wrong. Strange indeed...
Sorry for bumping, but i really hope someone can enlighten me on this.
is working on a reply...