November Happy Hour will be moved to Thursday December 5th.

Get parent page block

Vote:
 

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?

#189963
Mar 28, 2018 12:48
Vote:
 

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

What do you want to do?

#189964
Mar 28, 2018 14:22
Vote:
 

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

#189965
Mar 28, 2018 14:47
Vote:
 

Only one or all blocks in the parent pages contentarea?

#189966
Mar 28, 2018 14:48
Vote:
 

Look at this one

https://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=119811

#189967
Mar 28, 2018 14:50
Vote:
 

Only one block.

#189968
Mar 28, 2018 14:54
Vote:
 

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

#189970
Mar 28, 2018 14:58
Vote:
 

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. 

#189971
Mar 28, 2018 14:59
Vote:
 

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)
#189972
Mar 28, 2018 15:04
Vote:
 

You are a life saver.

#189974
Mar 28, 2018 15:11
Vote:
 

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

#189980
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.