Hopefully this will be a simple answer for someone. I have an Umbraco V4 site with the following XSLT for a menu, the only problem is this creates a menu from the top level of the site but I want to only show a menu from a certain node downwards. I assume I have to put something like this in:
Thanks for the reply, I tried that but the trouble is depending what page I am on I get a different menu, this is because of the way that my site is structured as shown below. I need this menu to only show the links to the Main menu pages even if I am currently viewing one of the footer menu pages hence why I need to specify exactly where to create the menu from:
Home - Main menu pages - Page 1 - Page 2 - Footer menu pages - Page 3 - Page 4 - Another page
This is where the navigation/sitemap "starts" from.
The select statement is basically saying... from whatever page the website visitor is viewing ($currentPage), go up the content tree (/ancestor) or use the current page if it already matches my requirements (-or-self), for any node (::node) WHERE (the square brackets are like a 'where' clause in sql if you're familiar with them) the node is at the first level of the content tree (@level = 1).
Hope that makes some sense :)
Anyway, the key is to change the bit within square brackets to meet your needs.
You don't want to start at the first level since that will give everything in the content tree. You could try any of these options. I think they will all work but give them a try and choose your favorite.
1. Hard-code the id of the 'Main menu pages' node, which you can find by hoving your mouse over that node in the content tree... that browser's status bar will show you it's id number. Your code would then look like this (assuming the id were 1234 in my example... update as appropriate):
3. Look for a unique document type (aka, @nodeTypeAlias). If your Main menu pages node is a unique document type you can look for it by its type rather than its id or where it exists in the content tree. Depending on how you built your site this might or might not be the case. But if it *is* unique you could do something like this (assuming the document type alias is 'MainMenuHolder' in my example... update as appropriate):
Be aware that this option won't work if the node doesn't have a unique document type associated with it.
At least one of those options should work for you. If not, tell us what was returned from each and that should help us find the right solution for you.
Thank you for the quick and detailed response, I have tried all three methods you suggested and each one has the following error when trying to save the XSLT:
(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, IList`1 parent) at
(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
And if I select skip testing then they all have the following error on the page:
Thanks for everyone's help on this one, I have managed to solve it for myself with the following change, I was pointed in the right direction by Doug and Rich. The change I made is as follows:
You can use the built-in XSLT template "List Subpages From A Changeable Source", where you add a contentPicker parameter to the macro. (Check the comment in the XSLT source for the correct name of the parameter.)
Menu from certain node instead of top level
Hopefully this will be a simple answer for someone. I have an Umbraco V4 site with the following XSLT for a menu, the only problem is this creates a menu from the top level of the site but I want to only show a menu from a certain node downwards. I assume I have to put something like this in:
But I'm not quite sure where because I created this menu from the sitemap template so it is by default designed to list the whole site structure:
Try changing:
to
Hi Rich,
Thanks for the reply, I tried that but the trouble is depending what page I am on I get a different menu, this is because of the way that my site is structured as shown below. I need this menu to only show the links to the Main menu pages even if I am currently viewing one of the footer menu pages hence why I need to specify exactly where to create the menu from:
Home
- Main menu pages
- Page 1
- Page 2
- Footer menu pages
- Page 3
- Page 4
- Another page
Guessing here but try something like
Rich
Just in case I wasn't clear
replace
with
Rich
Thanks for the reply, I tried that but it has an error parsing XSLT file. Any other suggestions?
Try clicking the Skip testing check box and saving.
Rich
I have already done that, the xslt error is on the page.
Sorry brain's not working too well today, someone will be along with another suggestion soon.
Ok, thanks for your help, is there anyone else with any suggestions on this?
Hi trfletch,
I'll try to help you out, but I need to be sure what you're expecting as output. Given your structure:
Home
- Main menu pages
- Page 1
- Page 2
- Footer menu pages
- Page 3
- Page 4
- Another page
You only want links to "Page 1" and "Page 2" (+ any future additions to "Main menu pages"), regardless of $currentPage?
/Chriztian
Rich is right that you only need to change the following line:
This is where the navigation/sitemap "starts" from.
The select statement is basically saying... from whatever page the website visitor is viewing ($currentPage), go up the content tree (/ancestor) or use the current page if it already matches my requirements (-or-self), for any node (::node) WHERE (the square brackets are like a 'where' clause in sql if you're familiar with them) the node is at the first level of the content tree (@level = 1).
Hope that makes some sense :)
Anyway, the key is to change the bit within square brackets to meet your needs.
You don't want to start at the first level since that will give everything in the content tree. You could try any of these options. I think they will all work but give them a try and choose your favorite.
1. Hard-code the id of the 'Main menu pages' node, which you can find by hoving your mouse over that node in the content tree... that browser's status bar will show you it's id number. Your code would then look like this (assuming the id were 1234 in my example... update as appropriate):
2. Only go to level 2, since your Main menu pages node is at that level (the Home node is at level 1 according to your description)
3. Look for a unique document type (aka, @nodeTypeAlias). If your Main menu pages node is a unique document type you can look for it by its type rather than its id or where it exists in the content tree. Depending on how you built your site this might or might not be the case. But if it *is* unique you could do something like this (assuming the document type alias is 'MainMenuHolder' in my example... update as appropriate):
Be aware that this option won't work if the node doesn't have a unique document type associated with it.
At least one of those options should work for you. If not, tell us what was returned from each and that should help us find the right solution for you.
cheers,
doug.
Hi Doug,
Thank you for the quick and detailed response, I have tried all three methods you suggested and each one has the following error when trying to save the XSLT:
And if I select skip testing then they all have the following error on the page:
Any ideas as to why this could be happening?
Chriztian,
Sorry, only just seen your response. Yes that is correct, I only want links to Page 1 and 2 regardless of where you are in the site.
Thanks for everyone's help on this one, I have managed to solve it for myself with the following change, I was pointed in the right direction by Doug and Rich. The change I made is as follows:
Chriztian Steinmeier:
Thats exactly what i want to do!
Do you have a solution for that?
Regards
\\Ronnie
Hi Ronnie,
What is it you want to do? The method I used has worked for me, let me know if you want an explanation
Hi Ronnie (+ others)
You can use the built-in XSLT template "List Subpages From A Changeable Source", where you add a contentPicker parameter to the macro. (Check the comment in the XSLT source for the correct name of the parameter.)
/Chriztian
Hello lads
My layout looks as follows
HOME
File
File
File
and i want to use HOME as index on the website, but i dont want it showing as meny item,
//Ronnie
Chriztian Steinmeier
Solved easily with your Suggestion
Thank you everyone
Regards
\\Ronnie
is working on a reply...