Reputation: 45
Is there a way in episerver to find parent block from a nested block?
For instance
Parent Block
Region (THis is IList)
Market(THis is IList)
Dept(THis is IList)
RegionContentArea
Region Block
Region (This will come from parent block)
MarketContentArea
Market Block
Market(This will come from parent block)
DeptContentArea
Dept Block
Dept (This will come from parent block)
Title & other properties
I tried using GetReferencesToContent() but this will work only for a single level hierarchy ie in the above case Region block.
var references = contentRepository.GetReferencesToContent(ownerContent.ContentLink, false).FirstOrDefault();
contentRepository.TryGet(references.OwnerID, references.OwnerLanguage, out ContentData owner);
If i use the same code for traversing through Market block ,it would give me Region block & not parent block. I know that there needs to be some looping around required but unable to get this as I am a newbie in episerver. Please help.
Upvotes: 0
Views: 681
Reputation: 163
This post on the Episerver Optimizely Forum may be helpful:
How to get a reference to a parent block from current block
Upvotes: 0