Howto inherit page banner?
Permalink
Hi guys,
I am trying to find a way to inherit a section banner to its descendants.
For example I have a page attribute image/file which I want to display from within the template:
How can its childs get this image automatically? Is there some kind of hierarchical level I can refer to or a general way to look to its parent levels getting those contents?
These images can unfortunately not be page defaults - they should be editable through the pages properties by any cms user...
Any idea?
Thanks much in advance
patte ;-)
I am trying to find a way to inherit a section banner to its descendants.
For example I have a page attribute image/file which I want to display from within the template:
<?php echo($c->getAttribute('myimage')->getVersion()->getRelativePath());?>
How can its childs get this image automatically? Is there some kind of hierarchical level I can refer to or a general way to look to its parent levels getting those contents?
These images can unfortunately not be page defaults - they should be editable through the pages properties by any cms user...
Any idea?
Thanks much in advance
patte ;-)
We have 12 general sites (using domain mapper) for health departments, containing different sections with special header images.
The client wants to be able to add new departments or new sections - every department or section with its own header - every child page should get this header automatically...
Is there no "level" I can refer to? I have a home page at level 1, departments at level 2 and sections at level 3. Isnt there a way to code this template side to acquire parent specific attributes?
Some kind of getParentbyLevel(2).getAttribute('myImage') ?
Some more tips??
patte
The client wants to be able to add new departments or new sections - every department or section with its own header - every child page should get this header automatically...
Is there no "level" I can refer to? I have a home page at level 1, departments at level 2 and sections at level 3. Isnt there a way to code this template side to acquire parent specific attributes?
Some kind of getParentbyLevel(2).getAttribute('myImage') ?
Some more tips??
patte
here is a way to do it, I'm on the same boat as you but I manage to get a bit farther
I have an attribute called "parent_banner" it's a checkbox, on the pages I have an area called "Banner" where I put in a image block, when I create a page that I want it to be the one dictating the banner image I add an image block to the area, then on it's child's I just check the attribute "parent_banner", all the child pages will display the image block from the parent area, if no "parent_banner" attribute is selected then I display an area to add blocks, the issue I'm having is that I have to manually edit the level that I want to use under the object array for $rcobj (that's why I said I was on the same boat) but at least this will get you somewhere.
I have an attribute called "parent_banner" it's a checkbox, on the pages I have an area called "Banner" where I put in a image block, when I create a page that I want it to be the one dictating the banner image I add an image block to the area, then on it's child's I just check the attribute "parent_banner", all the child pages will display the image block from the parent area, if no "parent_banner" attribute is selected then I display an area to add blocks, the issue I'm having is that I have to manually edit the level that I want to use under the object array for $rcobj (that's why I said I was on the same boat) but at least this will get you somewhere.
<?php if ($c->getCollectionAttributeValue('parent_banner')) { $nh = Loader::helper('navigation'); $cobj = $nh->getTrailToCollection($c); $rcobj = array_reverse($cobj); if (is_object($rcobj[1])) { $pID = $rcobj[1]->getCollectionID(); $parentPage = Page::getByID($pID); // Get the blocks that have been added on the parent page in the // specified area. In this case we assume you called yours Banner $parentBlocks = $parentPage->getBlocks('Banner'); // 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)) {
Viewing 15 lines of 26 lines. View entire code block.
looking up the tree for a specific block would be possible with some recursive math - but i'd be concerned about performance if your site got bit...