I try to display content from multiple nodes in my magazine. I have several acrhieve pages for each category (sport / music / tech / etc) but I want in one page to show all the news - how do I do it?
This is my code:
dynamic node = Library.NodeById(1095);
var pagesToList = @node.Children.Where("Visible");
Then under it I have the magazine folder which inside it (childs) the magazine (archieve) pages - sport / music / tech / lifestyle / etc. then (in parrallel to the magazine-archieve pages) I have folder for each category - sport / music / tech - which inside each catgegory I have another folder - 2013 then news folder - then the news pages with the properties - title / articleImg / metaDescription - which is also the article summary which show at the magazine pages and home pages
I think what he wants to do is trying to do is start from Root(Home) and recusivly go into each of the sub nodes. Select the news page and render it out?
Home
>Node
> Archive
> News (Render Me)
>Node
> Archive
> News (Render Me)
> Node
> Archive
> News (Render Me)
I could be really along way off. Screen shot would be really usefull. Thanks. Charlie :)
For this type of scenario I love to use the XPath operator (yes, this works in Razor!) as follows:
dynamic node = Library.NodeById(1095); // starting/common ancestor node
var pagesToList = @node.XPath(".//newsItem").Where("Visible"); //assume the pages you want displayed are actually called "newsItem"
The XPath query will descend all the way down the tree, grabbing anything named "newsItem".
You can also throw an OrderBy() on the returned collection, maybe even a Take(), for instance if you wanted to display the last 5 updated news items.
How to display multiple nodes?
Hello,
I try to display content from multiple nodes in my magazine. I have several acrhieve pages for each category (sport / music / tech / etc) but I want in one page to show all the news - how do I do it?
This is my code:
I tried to change from
to
But it didn't work and I got error ...
How do I do it? Is there any way to do it
Thanks.
Hi Meni,
Can you show me how your content is structured in the backend ?
Dave
Yes,
Home Page.
Then under it I have the magazine folder which inside it (childs) the magazine (archieve) pages - sport / music / tech / lifestyle / etc. then (in parrallel to the magazine-archieve pages) I have folder for each category - sport / music / tech - which inside each catgegory I have another folder - 2013 then news folder - then the news pages with the properties - title / articleImg / metaDescription - which is also the article summary which show at the magazine pages and home pages
Hey Meni,
It might be better to take a screenshot and post it here.
Rich
I think what he wants to do is trying to do is start from Root(Home) and recusivly go into each of the sub nodes. Select the news page and render it out?
Home
>Node
> Archive
> News (Render Me)
>Node
> Archive
> News (Render Me)
> Node
> Archive
> News (Render Me)
I could be really along way off. Screen shot would be really usefull. Thanks. Charlie :)
Have a look at the Site Map XSLT / Razor template that comes out the box with Umbraco, this can be modified to do this.
Rich
For this type of scenario I love to use the XPath operator (yes, this works in Razor!) as follows:
The XPath query will descend all the way down the tree, grabbing anything named "newsItem".
You can also throw an OrderBy() on the returned collection, maybe even a Take(), for instance if you wanted to display the last 5 updated news items.
Best of luck!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.