Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Umbraco v7.4.2 / Archetype v1.12.3
Hi,
I have a partial view which shows news items on a page, i'd like to use this same partial on the page's children, how can I make it recursive to pull the news items from the parent - or is there a better way?
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Archetype.Models; @using Archetype.Extensions; @if (Model.Content.GetPropertyValue<ArchetypeModel>("news").Any()) { <ul id="tape"> @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("news")) { <li> <span>@fieldset.GetValue("date") -</span> @if (fieldset.HasValue("link")) { <a href="@fieldset.GetValue("link")"> @fieldset.GetValue("title")</a> } else { @fieldset.GetValue("title") } </li> } </ul> }
Any help would be greatly appreciated.
Thanks Kerri
Hi Kerri.
The second parameter to GetPropertyValue(string alias, bool recurse) might help you? So if you change your code to:
@if (Model.Content.GetPropertyValue<ArchetypeModel>("news", true).Any()) { <ul id="tape"> @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("news", true)) { <li> <span>@fieldset.GetValue("date") -</span> @if (fieldset.HasValue("link")) { <a href="@fieldset.GetValue("link")"> @fieldset.GetValue("title")</a> } else { @fieldset.GetValue("title") } </li> } </ul> }
Above code is not tested, just a thought...
Thanks Dennis,
Was having one of those moments! - i'd tried ("news"),true !
("news"),true
Cheers Kerri
Great Kerri!! Glad it worked for you!!!
Have a great day and best of luck with the rest of your site!!
All the best!
/ Dennis
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.
Continue discussion
Recursive fields
Umbraco v7.4.2 / Archetype v1.12.3
Hi,
I have a partial view which shows news items on a page, i'd like to use this same partial on the page's children, how can I make it recursive to pull the news items from the parent - or is there a better way?
Any help would be greatly appreciated.
Thanks Kerri
Hi Kerri.
The second parameter to GetPropertyValue(string alias, bool recurse) might help you? So if you change your code to:
Above code is not tested, just a thought...
Thanks Dennis,
Was having one of those moments! - i'd tried
("news"),true
!Cheers Kerri
Great Kerri!! Glad it worked for you!!!
Have a great day and best of luck with the rest of your site!!
All the best!
/ Dennis
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.