Accessing blocks in Page list override
Permalink
So I have a page list block on the home page.
I want it to show one page only in the area.
It looks like page lists are intended to get attributes rather than page content.
I have been looping thru the code below trying to get a block called "Statistic Image" but its always empty. Is it not possible to access blocks in page list?
DOH! page was empty so that accounts for some of that.....
I want it to show one page only in the area.
It looks like page lists are intended to get attributes rather than page content.
I have been looping thru the code below trying to get a block called "Statistic Image" but its always empty. Is it not possible to access blocks in page list?
DOH! page was empty so that accounts for some of that.....
Thanks. I finally found part of my answer here:
http://www.concrete5.org/community/forums/customizing_c5/theoretica...
Contained in here is some really crucial distinctions concerning C5 and page lists and building sites.
So now if i have the block data i am still wondering which part of the array in $blocks actually provides the data. $blocks is a huge array some of the content of which is serialised ?!?
How do you render/access the array properly to get the block?
http://www.concrete5.org/community/forums/customizing_c5/theoretica...
Contained in here is some really crucial distinctions concerning C5 and page lists and building sites.
So now if i have the block data i am still wondering which part of the array in $blocks actually provides the data. $blocks is a huge array some of the content of which is serialised ?!?
How do you render/access the array properly to get the block?
foreach ($pages as $page): $blocks = $page->getBlocks('Statistic Text'); $blocks->????
This might help:
http://www.concrete5.org/marketplace/addons/page-list-teasers/...
If you park the "Statistic Text" block in the 'Main' area on the page then Page List Teasers will grab it's content.
http://www.concrete5.org/marketplace/addons/page-list-teasers/...
If you park the "Statistic Text" block in the 'Main' area on the page then Page List Teasers will grab it's content.
Yes it does help thanks.
In fact it helped me 'cheat'.
Using Jordans installed add on i borrowed it's helper for a leg up :)
So my page list template looks like:
Note: for anyone reading/discovering the blocks 'Statistic Image' are referencing a block on a custom page template.
In fact it helped me 'cheat'.
Using Jordans installed add on i borrowed it's helper for a leg up :)
So my page list template looks like:
<?php defined('C5_EXECUTE') or die("Access Denied."); $teaserBlockCount = ($controller->truncateSummaries ? 1 : null); $teaserTruncateChars = ($controller->truncateSummaries ? $controller->truncateChars : 0); $plth = Loader::helper('page_list_teasers', 'page_list_teasers'); $th = Loader::helper('text'); foreach ($pages as $page): $statImage = $plth->getPageTeaser($page, 'Statistic Image', $teaserBlockCount, $teaserTruncateChars); $statText = $plth->getPageTeaser($page, 'Statistic Text', $teaserBlockCount, $teaserTruncateChars); ?> <div class="text-box"> <div class="visual"> <?php echo $statImage; ?> </div> <div class="frame">
Viewing 15 lines of 21 lines. View entire code block.
Note: for anyone reading/discovering the blocks 'Statistic Image' are referencing a block on a custom page template.
Cheat? Open Source + MIT + Free Add-on means that cheating is allowed and encouraged. How do you think we all learned to build in concrete5. Now excuse me while I steal your work and extend it in one of my projects!
UPDATE: After working with the code, I realize that my post above may lead people in the wrong direction. For alanski's code to work, you must have editable areas named 'Statistic Image' and 'Statistic Text' built into the Page Type file that is being grabbed by the Page List block. You can edit the code to reflect the names of the editable areas you actually have in your Page Type files. The template will grab the number of blocks from these areas depending on the configuration of the Page List block (using the Page List Teasers settings). This also assumes you have the free "Page List Teasers" add-on installed on your site.
http://www.concrete5.org/marketplace/addons/page-list-teasers/...
UPDATE: After working with the code, I realize that my post above may lead people in the wrong direction. For alanski's code to work, you must have editable areas named 'Statistic Image' and 'Statistic Text' built into the Page Type file that is being grabbed by the Page List block. You can edit the code to reflect the names of the editable areas you actually have in your Page Type files. The template will grab the number of blocks from these areas depending on the configuration of the Page List block (using the Page List Teasers settings). This also assumes you have the free "Page List Teasers" add-on installed on your site.
http://www.concrete5.org/marketplace/addons/page-list-teasers/...
https://www.concrete5.org/community/forums/customizing_c5/modify_pag...