Inherit Block Properties

Permalink
Is it possible for child pages to inherit the block properties from its parent page?

For example my site has five main pages each with sub pages. I would like the auto-nav block on each of those sub pages to be inherited when the new page in that subsection is created rather than have to apply the block to each new page. This way my client just has to create a new page in the right place and not worry about setting up the auto-nav block as it will be done automatically.

 
ScottC replied on at Permalink Reply
ScottC
this reeks of page_type defaults which you can do in the dashboard.
Galapogos replied on at Permalink Reply
I realize this is an old thread but I spent some time looking for a solution to this problem and couldn't find any that didn't involve scrap booking or other browser based solutions. So I figured I'd post what I came up with in hopes it helps someone else or that maybe someone even offers a better solution:

// Get the parent page object
$parentPage = Page::getByID($c->getCollectionParentID());
// Get the blocks that have been added on the parent page in the
// specified area. In this case we assume you called yours Auto Nav
$parentBlocks = $parentPage->getBlocks('Auto Nav');
// If the parent page already has this block(s) installed we 
// don't need to have the user enter another one for its 
// child pages
if (!empty($parentBlocks)) {
   // For every block instance in that area we will display it
   foreach ($parentBlocks as $block) {
      $block->display();
   }
}
// If the parent page doesn't have the autonav configured


This code will only work on page deep under the main page since a new child page under child #1 will try to read child #1's blocks which it won't have because it's simply displaying the blocks of the main parent page. In that case you'd just need to whip up a function that will find the ID of the main parent page for that section. Something that finds the highest parent page ID in the tree that's > 1 or something like that. Maybe Concrete even has a method that does that. Who knows? I'm a Concrete noob.
mdzoidberg replied on at Permalink Reply
mdzoidberg
This is exactly what I was looking for, thanks for posting your code.
Shopimport replied on at Permalink Reply
Shopimport
I like the 'Setup on Child Pages' function. However it's avialble only on the page type.

I would love to see this function on a regular page. I split the site in sections and each section can have it's own editor user. They don't have access to dashboard and page types.

If on the main page of the section you can do 'Setup on Child pages' and it will iterate blocks to all child and children pages within the navigation tree based on area name then this would be great. So it should not even limit to the same page type.

I see other solutions based on the area name, but I only want some blocks within the area as other blocks might still be unique per page.

Suggestions are very well, either on existing modules or on developing approach were to start.
frz replied on at Permalink Reply
frz
Hmm to me this sounds like some more unique page types during
architecture could have got you what you need today. Since pages
inherit a lot of their information from page types/defaults it makes
sense to me to have that copy tool there. It isn't the most graceful
of tools on earth as it is today - for example try copying out a block
that's half way down a sidebar while maintaining sort order across
pages with varrying content in that side bar.. it doesn't work out
great. I think adding that type of functionality to the general
editing experience might confuse the average joe more than help them.

I still believe you probably wouldn't need this if you had more
content specific page types instead of layout specific ones... Product
Page, and Press Release instead of Left Sidebar, Right sidebar.

best wishes

Franz Maruna
CEO - concrete5.org
http://about.me/frz