Inherit property value from parent page & combining with current page
Hi,
I'm hoping to find the best solution for this requirement below.
My node tree looks like this:
Home
- Sub1
- Sub2
- Sub3
Home is Doctype "Home", Sub3 is Doctype "HomeSpecial". HomeSpecial inherits from Home. Both Home and Sub3 have ArchetypeModel properties which I use to display a rotating banner, called "Features" (Defined on the "Home" doctype).
When Sub3 is requested I want to show both Home's Features property contents and Sub3's Features property contents in the rotating banner.
Personally I'd go with handling this in the front-end (either controller or view). Do something like this:
var parentFeature = Model.Content.Parent.GetPropertyValue<ArchetypeModel>("feature");
var currentFeature = Model.Content.GetPropertyValue<ArchetypeModel>("feature");
var combined = new List<ArchetypeFieldsetModel>();
combined.AddRange(parentFeature.Fieldsets);
combined.AddRange(currentFeature.Fieldsets);
foreach (var item in combined)
{
...
}
Basically you're making a new (empty) list of the fieldsets, then adding the parent fieldsets, then the ones from the current page.
Inherit property value from parent page & combining with current page
Hi,
I'm hoping to find the best solution for this requirement below.
My node tree looks like this:
Home
- Sub1
- Sub2
- Sub3
Home is Doctype "Home", Sub3 is Doctype "HomeSpecial". HomeSpecial inherits from Home. Both Home and Sub3 have ArchetypeModel properties which I use to display a rotating banner, called "Features" (Defined on the "Home" doctype).
When Sub3 is requested I want to show both Home's Features property contents and Sub3's Features property contents in the rotating banner.
Thanks in advance.
Hi David,
Did you want to combine the values in the editor itself (back-office)? or only on the front-end?
If it's only on the front-end, how are you currently getting the values from your Archetype property? (via a controller or code in the view directly?)
The general idea would be to get both
ArchetypeModel
objects and combine their fieldsets - then render them out.Cheers,
- Lee
Hi Lee,
Thanks for the response.
I hadn't thought about combining the values in the backend - but this would be a good option. Is there a way you can suggest to achieve this?
Alternatively, I can combine in the front-end. I'm currently rendering the ArchetypeModel properties in a partial view:
Then looping through:
Hi David,
Personally I'd go with handling this in the front-end (either controller or view). Do something like this:
Basically you're making a new (empty) list of the fieldsets, then adding the parent fieldsets, then the ones from the current page.
Hope this helps?
Cheers,
- Lee
Thanks for the help, Lee. I'll give this approach a go.
Cheers,
David.
is working on a reply...