Page List Templates and Custom Blocks

Permalink
I've been trying to set up a custom blog-like interface through the use of page types and the page list block. I have a page type with an Image block (with a block name of "Thumbnail Image") and a Content block (with a block name of "News Content") in the defaults (for creating a new page through composer). Now, I am trying to create a new template for my Page List block.

The problem I'm having is that I can't seem to figure out how to access the saved data for my Image and Content blocks through my Page List template. I've been trying to use the blog_index_thumbnail.php template as a reference, but what's being done in there doesn't seem to work for me.

This is basically what I'm trying in my template file:

for ($i = 0; $i < count($cArray); $i++ ) {
   $cobj = $cArray[$i]; 
   $cobj->getBlocks('Thumbnail Image');   // this returns an empty array
}

dzimney
 
olliephillips replied on at Permalink Reply
olliephillips
I think your $cobj->getBlocks('Thumbnail Image') call will be looking for blocks in an area. You don't say if your page type includes an area called 'Thumbnail Image' but given that's the name of your block I'm guessing not, which would explain your empty array.

If you leave out the argument you'll get an array of all the blocks on the page. You then need check each block's handle and get it's properties. Fine if you only have the one image block

If you pass the argument you can restrict the search to an area. If you will have other images on the same page, passing the area your thumbnail image block is in makes it simpler.