Referencing a programmatically created block on another page
Permalink
My client doesn't like lots of manual CMS editing of choosing (or even defaulting) blocks as part of the user editing process, so we have a number of templates that have blocks programmatically added.
One of these is a Tag List block that shows the Tags associated with the page - great.
However, on an index page for these children pages, I need to display page information such as title, date published, etc and the Tags associated with it.
I was hoping to use the collection object of the destination page (I have an array of all of the children pages being displayed) and read the instance of the programmatically generated block on the destination page to re-show the Tags for that page. However, all the documentation seems to grab blocks by ID or Area, etc and I know none of these things as the block is added programmatically.
How can I access the destination page block and grab / re-render the contents on the current index page? Urgent help most appreciated.
Gav
One of these is a Tag List block that shows the Tags associated with the page - great.
However, on an index page for these children pages, I need to display page information such as title, date published, etc and the Tags associated with it.
I was hoping to use the collection object of the destination page (I have an array of all of the children pages being displayed) and read the instance of the programmatically generated block on the destination page to re-show the Tags for that page. However, all the documentation seems to grab blocks by ID or Area, etc and I know none of these things as the block is added programmatically.
How can I access the destination page block and grab / re-render the contents on the current index page? Urgent help most appreciated.
Gav
Is the block added in the template or what( so the tags are hardcoded)?
Added to the page template. Example:
$pageCatList = BlockType::getByHandle('tags'); $pageCatList->controller->displayMode = 'page'; $pageCatList->controller->targetCID = $resultsPageID; $pageCatList->render('tag-list');
ohh, I see. Do this
and the tags should be outputted in their array.
//$page is the child pages we're looping through $tags = $page->getAttribute('tags');//get the data stored in the attribute print_r($tags);
and the tags should be outputted in their array.
Thank you. I'll try it out. I think I was over-thinking it!
Thanks for the fast response, sir.
Thanks for the fast response, sir.