How to programmatically access page set properties?

Permalink
I am making a custom page_list template for my custom page type.
In form output for the page I have added a set with various content blocks that make up the page (see attached screen shot). How can I access these blocks to display in my list?

Thanks

1 Attachment

 
pvernaglia replied on at Permalink Best Answer Reply
pvernaglia
I think it is easier to use Page Attributes than Content Blocks when you are working with Page templates and Page Lists. They are easier to grab and you can set up Composer for adding and editing the pages.

You can grab the Content Blocks from a page and loop through them with a foreach

$pBlocks = $page->GetBlocks();
    foreach ($pBlocks as $pBlock){
    if ($pBlock->btHandle == 'content') {
       $blockContent = $pBlock->getInstance();
            echo $blockContent->getContent();
   }
}
d0nkeykong replied on at Permalink Reply
Thanks pvernaglia.
After posting I did take a good look around the forums and it feels that attributes are much better in most cases so I will use them I think.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi d0nkeykong,

That is a good question. Off the top of my head, I am not sure how to get Content block contents programmatically.

Now that you have brought it up, I am interested in knowing too.

In the meantime, if you don't need rich text, you can switch the Content blocks to Text Area attributes. The attributes can then be pulled in and displayed in your Page List template.
d0nkeykong replied on at Permalink Reply
Hi MrKDilkington.

I have to agree after a few hours of playing around with the system.
Text attributes seems like the best option so I have scrapped the idea of using blocks :)