Try our conversational search powered by Generative AI!

Get parent page block


I am trying to get the parent block (which is a property) in the child page. 

I got this 

var page = contentRepository.Get(currentPage.ParentLink);

But how to get the property?

Mar 28, 2018 12:48

Now you get the parent page to the currentpage, nothing to do with blocks.

What do you want to do?

Mar 28, 2018 14:22

Now I am trying to get refrence to my parent pages block. Let say the block name is "ABC". I want to show the same block on child pages

Mar 28, 2018 14:47

Only one or all blocks in the parent pages contentarea?

Mar 28, 2018 14:48

Look at this one

Mar 28, 2018 14:50

Only one block.

Mar 28, 2018 14:54

Ok, then look in the link I linked earlier, that way you can first get the parent page contentarea (either strongly typed of with .Propery[""] and then loop through the content areas blocks to you find the one you are looking for.

I would say that it feels like a hack for somehting the editor can do them self by adding the block in both pages

Mar 28, 2018 14:58

Yeah I agree, the issue is that there are a lot of child pages and then all the child pages would have to create that block manually. 

Mar 28, 2018 14:59

Then create a new property on the parent page with a contentarea for those blocks that will be inherited and then create a instans of the parent page in the viewmodel and then just render that property on the child pages.

@Html.PropertyFor(x => x.ParentPage.InheritedBlocksContentAreaProperty)
Mar 28, 2018 15:04

You are a life saver.

Mar 28, 2018 15:11

Thanks!!, please mark it as an answer if you think it solved your problem

Mar 28, 2018 17:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.