Question

I'm using Glass.Mapper for an actual project and need to implement value inheritance.

I have for example meta keywords, which i want to map into a Glass.Mapper model. If the field is empty, i want to find the nearest parent item which has a value in that field and use that value in my current model.

The field is a Single-Line Text named Meta Keywords.

Home Item -> "Keyword1, Keyword2"
    First Child -> Empty
        Current Item -> Empty

Because the current item has no field value, i want to do a recursive check and get the value Keyword1, Keyword2 from the Home Item within my current Glass.Mapper model.

What would be the best approach to do that? I know there is a Field Fallback module out there, which does that type of things and sets the value as the Standard Value of the current item dynamically. Does Glass.Mapper provides some functionality to do this in a simpler way?

Was it helpful?

Solution

The Field Fallback Module is probably your best bet for this. We are using Glass Mapper and Field Fallback (Sean Kearney's module) to provide language fallback. We ran into issues getting lateral fallback working (w/MVC, can't speak to a web forms implementation). Ancestor fallback should do exactly what you are looking for.

I'm not aware of any way to get Glass to do this automatically. I have a few thread on the Glass Google Group, here is one related to field fallback: https://groups.google.com/forum/#!topic/glasssitecoremapper/-uUsb229LzM

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top