The code works great, however I have my site tree set up as follows:
-index
--about
--products
---prod 1
---prod2
--contact
now when I am on the product page everything is great, however when I am on the index page I get the list of all of the children which I do not want. How can I avoid this?
Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?
[quote=Ruben]I'm not sure if I understood this well: what output would you want on the index page instead?[/quote]
no output, I have a navigation bar already
[quote=Ewatkins]it would send me to /products/contact.aspx instead of aspx[/quote]
You mean, relative path instead of absolute? Mmm... shouldn't be the case with NiceUrl. Can you give the HTML output generated?
I rewrote a little and added a section so that when I am on a prod page, I can still see the sibling links, but now when I am on index, about, contact (because they dont have child pages) I am getting a list of all of the siblings. All of the pages without a level under them (an index) should not show anything...any ideas..here is my new code:
[quote=Ruben]Looks like "@level=$currentPage/@level" is not a children, but a sibling test ;)[/quote]how can I fix that? Also what html do you want to see to see what the relative paths are doing..you can view the site if you wish at testserver1.carbintech.com/index.aspx so you can get a feel for what it is doing..it is the list of links on the left of the site
I think you're loosing yourself a bit in the complexity of this XSLT file. The comments don't match the functionality, which makes it hard to get a grasp of what's happening.
[quote=Ewatkins]Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?[/quote]
I found the problem when looking at your site: your top menu uses relative paths... try using absolute paths (e.g. /contact.aspx instead of contact.aspx). Does that work?
I am modifying some previous xslt that is why it is like that..now here is what needs to be done..
The site tree:
index
--products
----prod 1
----prod2
----prod3
----prod etc..
--about us
--metrology
----link 1
----link 2
----link etc..
--contact
--customer support
----link
----link
----link
now on the home page I need there to not be any subnodes shown in this macro..in the about and contact I need the same, no child nodes or sibling nodes, now in the pages that have child nodes (level2 i believe) I need them to show the child nodes, and if I am on one of those child nodes, show the sibling nodes..
[quote=Ruben][quote=Ewatkins]Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?[/quote]
I found the problem when looking at your site: your top menu uses relative paths... try using absolute paths (e.g. /contact.aspx instead of contact.aspx). Does that work?[/quote]
genius I cant believe I looked over that, thanks so much for that..now if i can get this xslt working I will be in good shape. :d/
[quote=Ewatkins]now if i can get this xslt working I will be in good shape. :d/ [/quote]
A closer examination reveals... that the "List Sub Pages By Level" XSLT template does exactly what you need ;)
Just create a new XSLT file, select "List Sub Pages By Level" in the template list, and that's it. Can you get that to work?
[quote=Ruben][quote=Ewatkins]now if i can get this xslt working I will be in good shape. :d/ [/quote]
A closer examination reveals... that the "List Sub Pages By Level" XSLT template does exactly what you need ;)
Just create a new XSLT file, select "List Sub Pages By Level" in the template list, and that's it. Can you get that to work?[/quote]
That is amazing I never would have though about that...Thanks for all the help man
No problem. The important thing to remember with XSLT is that easy selections in words always have easy counterparts in XPath notation. When you see appearing a lot of if and choose statements, you probably need to simplify things.
Ok one more question, if you check out the page again, I have the featured product, now in the back end I have featured products and under it the featured product that I show. On that page I dont want there to be a link in the left hand side that shows the children of featured products, any way to not show the children of that node?
I can either suggest
a) using another template there
b) adding an if to the xslt file, which checks for the parent node. If it's "feature-products", then don't show it
c) not showing the level 2 links when there is only 1 level 2 page
[quote=Ruben]I can either suggest
a) using another template there
b) adding an if to the xslt file, which checks for the parent node. If it's "feature-products", then don't show it
c) not showing the level 2 links when there is only 1 level 2 page[/quote]
I was trying to do an if but I am not that familiar with xslt, any tips? I know it should be something like:
Child Nodes question
I am writing xslt to show the child nodes and link them to the appropriate place, however I am having some difficulty. Here is my xslt..
]>
<>
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">
The code works great, however I have my site tree set up as follows:
-index
--about
--products
---prod 1
---prod2
--contact
now when I am on the product page everything is great, however when I am on the index page I get the list of all of the children which I do not want. How can I avoid this?
I'm not sure if I understood this well: what output would you want on the index page instead?
Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?
[quote=Ruben]I'm not sure if I understood this well: what output would you want on the index page instead?[/quote]
no output, I have a navigation bar already
[quote=Ewatkins]no output, I have a navigation bar already[/quote]
You could check the level of the currentPage, and hide it then for the top level.
[quote=Ewatkins]it would send me to /products/contact.aspx instead of aspx[/quote]
You mean, relative path instead of absolute? Mmm... shouldn't be the case with NiceUrl. Can you give the HTML output generated?
I rewrote a little and added a section so that when I am on a prod page, I can still see the sibling links, but now when I am on index, about, contact (because they dont have child pages) I am getting a list of all of the siblings. All of the pages without a level under them (an index) should not show anything...any ideas..here is my new code:
]>
<>
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">
[code]
[quote=Ruben]Looks like "@level=$currentPage/@level" is not a children, but a sibling test ;)[/quote]how can I fix that? Also what html do you want to see to see what the relative paths are doing..you can view the site if you wish at testserver1.carbintech.com/index.aspx so you can get a feel for what it is doing..it is the list of links on the left of the site
I think you're loosing yourself a bit in the complexity of this XSLT file. The comments don't match the functionality, which makes it hard to get a grasp of what's happening.
[quote=Ewatkins]Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?[/quote]
I found the problem when looking at your site: your top menu uses relative paths... try using absolute paths (e.g. /contact.aspx instead of contact.aspx). Does that work?
I am modifying some previous xslt that is why it is like that..now here is what needs to be done..
The site tree:
index
--products
----prod 1
----prod2
----prod3
----prod etc..
--about us
--metrology
----link 1
----link 2
----link etc..
--contact
--customer support
----link
----link
----link
now on the home page I need there to not be any subnodes shown in this macro..in the about and contact I need the same, no child nodes or sibling nodes, now in the pages that have child nodes (level2 i believe) I need them to show the child nodes, and if I am on one of those child nodes, show the sibling nodes..
Do you understand what I am trying to do?
Ok, I understand. Just a moment... I'll try this one.
[quote=Ruben][quote=Ewatkins]Also when linking using the code above, everything is fine if I go into a child node, but when I try to go back to a parent node (ie if I am on prod1 and try to go to contact) it links me to the wrong place (it would send me to /products/contact.aspx instead of aspx) what can I do to fix that?[/quote]
I found the problem when looking at your site: your top menu uses relative paths... try using absolute paths (e.g. /contact.aspx instead of contact.aspx). Does that work?[/quote]
genius I cant believe I looked over that, thanks so much for that..now if i can get this xslt working I will be in good shape. :d/
[quote=Ewatkins]now if i can get this xslt working I will be in good shape. :d/ [/quote]
A closer examination reveals... that the "List Sub Pages By Level" XSLT template does exactly what you need ;)
Just create a new XSLT file, select "List Sub Pages By Level" in the template list, and that's it. Can you get that to work?
[quote=Ruben][quote=Ewatkins]now if i can get this xslt working I will be in good shape. :d/ [/quote]
A closer examination reveals... that the "List Sub Pages By Level" XSLT template does exactly what you need ;)
Just create a new XSLT file, select "List Sub Pages By Level" in the template list, and that's it. Can you get that to work?[/quote]
That is amazing I never would have though about that...Thanks for all the help man
No problem. The important thing to remember with XSLT is that easy selections in words always have easy counterparts in XPath notation. When you see appearing a lot of if and choose statements, you probably need to simplify things.
Ok one more question, if you check out the page again, I have the featured product, now in the back end I have featured products and under it the featured product that I show. On that page I dont want there to be a link in the left hand side that shows the children of featured products, any way to not show the children of that node?
here is an example of what I am talking about..I need feature-products to not show any children in the side bar..
http://testserver1.carbintech.com/featured-products/mahr-federal-digital-caliper-4102901.aspx
I can either suggest
a) using another template there
b) adding an if to the xslt file, which checks for the parent node. If it's "feature-products", then don't show it
c) not showing the level 2 links when there is only 1 level 2 page
[quote=Ruben]I can either suggest
a) using another template there
b) adding an if to the xslt file, which checks for the parent node. If it's "feature-products", then don't show it
c) not showing the level 2 links when there is only 1 level 2 page[/quote]
I was trying to do an if but I am not that familiar with xslt, any tips? I know it should be something like:
Try:
[code][/code]
where 1234 is the ID of your node.
Doing this:
gives me nothing under my menu, it takes away all of the children..
Indeed... because there is no id there. I think you need $currentPage/@id ;)
so
$currentpage/ancestor::node@id!=1234 ?
is working on a reply...