Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:10
    Evan
    0

    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?

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:23
    Ruben Verborgh
    0

    I'm not sure if I understood this well: what output would you want on the index page instead?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:23
    Evan
    0

    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?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:24
    Evan
    0

    [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

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:27
    Ruben Verborgh
    0

    [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.

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:29
    Ruben Verborgh
    0

    [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?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:40
    Evan
    0

    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">

















  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:41
    Ruben Verborgh
    0

    [code]

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:43
    Evan
    0

    [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

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:45
    Ruben Verborgh
    0

    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.

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:47
    Ruben Verborgh
    0

    [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?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:49
    Evan
    0

    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?

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 18:50
    Ruben Verborgh
    0

    Ok, I understand. Just a moment... I'll try this one.

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 18:50
    Evan
    0

    [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/

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 19:13
    Ruben Verborgh
    0

    [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?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 19:16
    Evan
    0

    [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

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 19:21
    Ruben Verborgh
    0

    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.

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 19:50
    Evan
    0

    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?

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 21:18
    Evan
    0

    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

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 21:45
    Ruben Verborgh
    0

    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

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 21:56
    Evan
    0

    [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:

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 22:03
    Ruben Verborgh
    0

    Try:
    [code][/code]
    where 1234 is the ID of your node.

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 22:12
    Evan
    0

    Doing this:


    gives me nothing under my menu, it takes away all of the children..

  • Ruben Verborgh 379 posts 30 karma points
    Jan 02, 2009 @ 22:31
    Ruben Verborgh
    0

    Indeed... because there is no id there. I think you need $currentPage/@id ;)

  • Evan 344 posts 99 karma points
    Jan 02, 2009 @ 22:32
    Evan
    0

    so

  • Ruben Verborgh 379 posts 30 karma points
    Jan 04, 2009 @ 11:26
    Ruben Verborgh
    0

    $currentpage/ancestor::node@id!=1234 ?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies