Copied to clipboard

Flag this post as spam?

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


  • Accusoft 58 posts 109 karma points
    May 13, 2011 @ 14:09
    Accusoft
    0

    Content from another page

    Ony one of my XSLT macros, I need to get content from another page.  For example, lets say I'm on the support page and want to display a list of products from the Products page.  currentPage only has support page data, how do I grab the nodes from products?

  • Peter Holmsgaard 69 posts 106 karma points
    May 13, 2011 @ 14:59
    Peter Holmsgaard
    0

    Hi Chris,

    I think the XSLT your are looking for is:

    <xsl:variable name="source" select="umbraco.library:GetXmlNodeById('THE ID OF THE PRODUCTS NODE')"/>
    <xsl:value-of select="$source/@nodeName"/> //nodeName of the "source"

    <xsl:for-each select="$source/* [@isDoc]"> //list of children of the "source"
       <xsl:value-of select="@nodeName"/><br/>
    </xsl:for-each>

    The source variable can replace your $currentPage param. Hope this helps :)

    Else I can recommend the umbraco tv guides..

    /Peter

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 13, 2011 @ 15:11
    Kim Andersen
    0

    Hi Chris

    As you wrote in another post you don't want to use the GetXmlNodeById, but find the nodes with xpath.

    Could you show us your content structure inside Umbraco? Then we'll be able to help you out with the correct xpath :)

    /Kim A

  • Accusoft 58 posts 109 karma points
    May 13, 2011 @ 15:15
    Accusoft
    0

    Hi Kim,

    Yes, just to clarify I have 2 sites that have the same basic structure but different NodeId's.  I copy data back and forth between them so it's important to use the path instead of the ID.

    I have /Content/Products which has a list of products underneath it.  I'm currently on the /Content/Support page and need to get that list of products.  It's not in the currentPage variable, I tried variations of /root/products but couldn't quite figure it out.  

    Thanks!

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 13, 2011 @ 15:19
    Kim Andersen
    0

    I think I know what you want to achieve. The product-node, does this have a unique document type, or can we be sure that the node name will never change?

    /Kim A

  • Accusoft 58 posts 109 karma points
    May 13, 2011 @ 15:21
    Accusoft
    0

    The node name will never change, but they also use separate document types - Products vs Support.

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 13, 2011 @ 15:25
    Kim Andersen
    0

    Okay you can try this:

    <xsl:for-each select="$currentPage/../Products/*[@isDoc]">
       
    <xsl:value-of select="@nodeName" /><br/>
    </xsl:for-each>

    This should run through the childnodes under the Products-node, if the alias of the document type is "Products".

    Does this work?

    /Kim A

  • Accusoft 58 posts 109 karma points
    May 13, 2011 @ 15:27
    Accusoft
    0

    Hi Kim,

    Worked perfect, thank you.  I there any way to do it based on the root?  Some of the items underneath support may use it as well.  

    Thank you very much for your help!

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 13, 2011 @ 15:30
    Kim Andersen
    0

    If I knew how your total structure looked like I could tell you for sure.

    But something like this should work:

     <xsl:for-each select="$currentPage/ancestor-or-self::*[@level='1']/Products/*[@isDoc]">
       
    <xsl:value-of select="@nodeName" /><br/>
    </xsl:for-each>

    If your homepage is on level 1, and the Products-node is on the next level the above code should work.

    /Kim A

  • Accusoft 58 posts 109 karma points
    May 13, 2011 @ 15:52
    Accusoft
    0

    Hi Kim,

    That's returning blank.  I've attached an image that shows the basic structure.

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 14, 2011 @ 00:34
    Kim Andersen
    0

    Ahh okay, try this instead:

    <xsl:for-each select="$currentPage/ancestor-or-self::root/Products/*[@isDoc]">
       
    <xsl:value-of select="@nodeName" /><br/>
    </xsl:for-each>

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft