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?
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?
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.
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.
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
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
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
It's a kind of sorting:
The sort parameter can also be a genereric property
hth, Thomas
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()<= 1">
[/code]
Change the number 1 to the number of items you want displayed.
Paul
Formatted incorrectly - 2nd attempt:
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
Rasb,
I think what these other guys are saying is that you can use the sort and then redirect to that page like this:
<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.
is working on a reply...