8.4.2 How to get content of page programmatically

Permalink
I have the blog set up. The Blog Entry page type form has a Content block. When a Blog Entry page is added with the Contents, I need the Page List block to show the page's contents too.

The page description is obtained with
$description = $page->getCollectionDescription();

How can I get contents of the Content block in the 'Main' area of a certain page type?

Thank you.

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
This worked:
if ($page->getCollectionTypeHandle() == 'article') {
    $blocks = $page->getBlocks('Main');
    foreach ($blocks as $block) {
        if ($block->btHandle == 'content') {
            $content = $block->getInstance()->getContent();
            if (!empty($content)) {
                echo $content;
                break;
            }
        }
    }
}