You could also do it like this, I think this is a more safer way to do it, because if the user deletes the node, and created it again then it will get a new id, and your code will throw an error when you are bind it to and specific id.
@foreach (var page in CurrentPage.AncestorOrSelf(1).Descendants("PortfolioItem").Take(4)){ //Do some stuff }
Portfolio Item Partial
Hello,
I am currently working on a 7.2 website.
My site structure is
Home>
Portfolio >
Portfolio Items
I am trying to create a partial view for the footer that selects the last 4 portfolio items. It is going to be rendered on the master layout.
How can i ensure that when i select the 4 items, they will be displayed even when i am on a portfolio item page?
Currently I have:
@foreach (var page in CurrentPage.DescendantsOrSelf("PortfolioItem").Take(4))
{
}
This works great until I am on a portfolio Item page, then it only sees the item I am on.
Thanks
Kind regards,
J
Use the umbraco helper instead.
var items = Umbraco.TypedContent(portfolioId).Children
Genius thank you :)
Hi James,
You could also do it like this, I think this is a more safer way to do it, because if the user deletes the node, and created it again then it will get a new id, and your code will throw an error when you are bind it to and specific id.
Hope this helps,
/Dennis
is working on a reply...