Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    May 17, 2010 @ 21:43
    Matt Taylor
    0

    Possible to display two content items on the same page?

    Hello,

    I'm new to Umbraco and this is my first post although I do have some experience with other CMS systems.

    I'm wondering if it is possible to do the following...

    I'd like to create a document type called "Sport" that simply has a Title property and a BodyText property.

    Then I'd like to create two content items that use this "Sport" document type, one called "Rugby" and the other called "Cricket".

    Is it possible to then create a Template that will display both of these content items on a single rendered page side by side?

    Thank you,

    Matt

  • Tommy Poulsen 514 posts 708 karma points
    May 17, 2010 @ 22:17
    Tommy Poulsen
    0

    Hi Matt, and welcome to the forum

    Sure it's possible.

    Say you have a content node setup like this:

    - sport
      - rugby
      - cricket

    You could choose to render the sport-node by rendering it's subnodes using an xslt macro (or inline xslt). In your Sport-Template you would add a macro call:

    <umbraco:Macro Alias="ShowMyChildren" runat="server"></umbraco:Macro>

     

    And in your ShowMyChildren macro you would add something like this:

    ...

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

      Title: <xsl:value-of select="@nodeName"/><br/>

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

    </xsl:for-each>

    ...

     

    But you probably want to check out documentation on setting up content nodes, templates and macros.

    >Tommy

     

     

  • Matt Taylor 873 posts 2086 karma points
    May 18, 2010 @ 11:42
    Matt Taylor
    0

    Thanks Tommy,

    That's useful to know.

    I've seen the videos on Document Types and templates so far. XSLT and Macros will be next.

    I'm used to a page based CMS and developing web user controls so this content based architecture and XSLT is quite a steep learning curve for me but I will get there.

    The idea I have is for each page to be rendered like an open book, the left hand side would show the "Rugby" content and the right would show the "Cricket" content.

    A link at the bottom of the rendered page would say 'Next page' which would then take you to a page that showed some "Soccer" content on the left and some "Hockey" content on the right.

                   <Header>
     Rugby  Cricket  Soccer  Hockey
    ___________  ____________
    |     Rugby      | |      Cricket      |
    |                     | |                       |
    |                     | |                       |   
    |                     | |                       |
    |                     | |                       |
    -----------------   -------------------
                                  Next page >
                    <Footer>

    Envisoning how to to set up the content nodes so they work with the menu is something I'm having trouble with.
    Each content item needs to appear in the menu as a link however clicking the Rugby or Cricket link need to display the same page with both content items on it.
    Likewise Soccer and Hockey need to display the same page.

    Can anyone offer any advice?

    I hope I have explained it OK.

    Thank you,

    Matt

  • Tommy Poulsen 514 posts 708 karma points
    May 18, 2010 @ 19:10
    Tommy Poulsen
    0

    Hi Matt

    One way of doing it would be to render your parent node template (e.g. the sport-node in my example above).

    The template for the sport-node would call a macro for rendering the subcontent (e.g. rugby/cricket or soccer/hockey). Distinguishing between what to show could be done in multiple ways, but I would consider adding some kind of attributes as url query string parameters, and then use this library function from the xslt macro to read the parameter values

    umbraco.library:RequestQueryStringThe questring string parameter could be the item number to show or whatever you find appropriate.

    You can see some examples on www.blackpoint.dk

    >Tommy

  • Matt Taylor 873 posts 2086 karma points
    May 19, 2010 @ 08:40
    Matt Taylor
    0

    Thanks again Tommy.

Please Sign in or register to post replies

Write your reply to:

Draft