Copied to clipboard

Flag this post as spam?

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


  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 15:55
    rasb
    0

    Displaying first subnode content on top level page

    Hi guys,

    I have tried to see if anyone had asked this before, but I can't seem to find it anywhere in the forum.

    Anyhow... I have website with a top level menu like most sites. One of those menu-items is called "News", and I have a number of news items below the News node.

    I now have an empty News page, with a right hand menu displaying a list of news items ordered by date. The same menu is available on each news item page.

    What I would like to do is just not have any content from the top News node, but always just display the latest news item. Is there a way I can do this easily and without duplicating the News Item Template I have created, or do I have to create macros separately for News top node and News Item?

    Is there a  call macro with first child or an embed subpage or something?

    Hope the question makes sense.

    /RasB

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2010 @ 19:48
    Dirk De Grave
    0

    Hmm, not sure if I completely understood. Can you give an visual example to clarify. Draw your content tree (or part of it) and show us what output is required on what page?

     

    Looking forward to your info.

     

    Cheers,

    /Dirk

  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 21:05
    rasb
    0

    Hi Dirk,

    Yes it was a bit murky. Let me try to draw my content tree.

    - Home
    - Products
    - News
    - News Item 1, Dec 2
    - News Item 2, Nov 4
    - News Item 3, Oct 6
    - News Item 4, Jul 8
    - News Item 6, May 15
    - Contact

    I have a top menu that is generated by an Xslt script. What I would like to achieve is to display the node named "News Item 1, Dec 2" when I press the menu item "News" in my top level navigation menu. 

    When I add a new news item then it will be placed at the top of the node tree below the "News" node. I always want to display the newest node below the "News" node when I navigate to the "News" node.

    Is that more clear?

    Thanks,
    RasB

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jan 19, 2010 @ 21:21
    Thomas Höhler
    0

    It's a kind of sorting:

    <xsl:for-each select="node[@nodeTypeAlias='NewsItem']">
    <xsl:sort select="@createDate" order="descending"></xsl:sort>

    The sort parameter can also be a genereric property

    hth, Thomas

     

  • Paul Blair 466 posts 731 karma points
    Jan 19, 2010 @ 21:53
    Paul Blair
    0

    if I have understood correctly you only want the first node so you will also need something like this within your for-each:

    [code]

    <xsl:for-each select="node[@nodeTypeAlias='NewsItem']">
      <xsl:sort select="@createDate" order="descending"></xsl:sort>
            <xsl:if test="position()&lt;= 1">

    [/code]

    Change the number 1 to the number of items you want displayed.

    Paul

  • Paul Blair 466 posts 731 karma points
    Jan 19, 2010 @ 21:55
    Paul Blair
    0

    Formatted incorrectly - 2nd attempt:

    <xsl:for-each select="node[@nodeTypeAlias='NewsItem']">
      <xsl:sort select="@createDate" order="descending"></xsl:sort>
            <xsl:if test="position()&lt;= 3">

     

  • rasb 162 posts 218 karma points
    Jan 22, 2010 @ 10:43
    rasb
    0

    Well... I almost found what I was looking for.

    umbracoRedirect actually does almost exactly what I want. I set the value of umbracoRedirect on my "News" node to the value of "News Item 1, Dec 2". I can do this manually for now.

    But what I really wanted was an umbracoRedirectToFirstChild, that would automatically just redirect to the latest node added or based on some criteria as sorting or a datefield.

    /RasB

  • Seth Niemuth 275 posts 397 karma points
    Jan 25, 2010 @ 10:27
    Seth Niemuth
    0

    Rasb,

    I think what these other guys are saying is that you can use the sort and then redirect to that page like this:

    <xsl:for-each select="node[@nodeTypeAlias='NewsItem']">
      <xsl:sort select="@createDate" order="descending"></xsl:sort>
            <xsl:if test="position()= 1">
    <script type="text/javascript">
    
    window.location = <xsl:value-of select="umbraco.library:NiceUrl(./@id)" />;
    
    </script>
    </xsl:if>
    </xsl:for-each>

    Then you would just put this macro on your news page and it would redirect to the first news item. 

     

Please Sign in or register to post replies

Write your reply to:

Draft