Copied to clipboard

Flag this post as spam?

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


  • Bill 2 posts 22 karma points
    Jan 31, 2012 @ 00:46
    Bill
    0

    Displaying Subnode Content On The Parent Content Page

    I've been having a lot of trouble figuring this out.

    What I want is a FAQ page that displays all the questions and answers on the same page. It gets the content from the questions and answers from subnode content.

    So for example my tree looks like this:

    FAQList
    Question1

    Question2

    Question3

     

    I want the template on FAQList to list the question and answer data from Question1...2... and 3 on the same page.

    Every time I try to find examples of this being done I can only find examples that list the subpages as links. I don't want to link to the subpages. I want to actually print the content from them onto the parent page. Is that possible?

    This is my attempt at it:

    <xsl:for-each select="$currentPage/node">

      Question: <xsl:value-of select="data [@alias = 'question']"/><br/>

      Answer: <xsl:value-of select="data [@alias = 'answer']"/><br/>

    </xsl:for-each>

     

    But I had no results. Help me out here. I'm banging my head on this.

  • Bill 2 posts 22 karma points
    Jan 31, 2012 @ 03:13
    Bill
    0

    Basically if I could just render each subnode's template on the parent node that would be wonderful!

  • Nigel Wilson 945 posts 2077 karma points
    Jan 31, 2012 @ 03:53
    Nigel Wilson
    0

    Hi Bill

    The code above relates to the old xml schema - are you running an older version of Umbraco ?

    To get all sub nodes you could do 

    <xsl:for-each select="$currentPage/*">

    This is a very shotgun approach as it will loop through all sub items.

    Alternatively you could relpace the asterisx with the alias of the sub node type to ensure you only get FAQ's.

    Hope this helps.

    Nigel 

  • Rodion Novoselov 694 posts 859 karma points
    Jan 31, 2012 @ 05:45
    Rodion Novoselov
    0

    Hi. A small erratum to what Nigel said:

    <xsl:for-each select="$currentPage/*[@isDoc]">

    (The difference is the "@isDoc" predicate)

  • Nigel Wilson 945 posts 2077 karma points
    Jan 31, 2012 @ 05:48
    Nigel Wilson
    0

    Good point Rodion

    Cheers

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft