Probably. CurrentPage is a dynamic node. I'm going to assume this code is in Razor and your view inherits from UmbracoTemplatePage or UmbracoViewPage. In which case just swap CurrentPage for Model.Content. Model.Content is an IPublishedContent object and you should then be away.
Also you may need to change the Children property to a method: Children() ?
Use Where to count a specific amount of child items that have a certain property
Hi All,
I currently have a list of "News Items" which are shown on the "News Page". Each "News Item" has a "Borough" and "Target Audience" meta tags on them.
For example: News Item 1 - is for Manchester and the target audience is Children.
How can i get each distinct value for borough and then count how many times that value shows up.
This is something i have at the moment but however the count seems a bit off... Well a lot.
}
To put this request into perspective here is a screen shot of some navigation i have created where i want to use the count of items.
If there is anythign you guys can provide to help or point me in the right direction!
Kind Regards,
Gary
I think you're after GroupBy so something like this:
Or something to that effect
FYI: Never knew about 'Pluck'. Thanks for that.
Hi David,
Your Welcome!
However, this looks like it may solve my problem. I have come across an issue.
Is this something you can assist with?
Thanks again for the help!
Cheers,
Gary
Probably. CurrentPage is a dynamic node. I'm going to assume this code is in Razor and your view inherits from UmbracoTemplatePage or UmbracoViewPage. In which case just swap CurrentPage for Model.Content. Model.Content is an IPublishedContent object and you should then be away.
Also you may need to change the Children property to a method: Children() ?
Got it!!
Changed it from this:
To this:
Works like a treat!
Thank you very much for your help!
Kind Regards,
Gary
is working on a reply...