Get blocks in child pages area

Permalink
Hi,

I'm trying to get all the blocks in the Main area of child pages.

I've tried this:
foreach($pages as $page) {
...
$inputArea = new Area("Main");
$blocks = $inputArea->getTotalBlocksInArea($page);
...
}


But it's returning Call to undefined method Concrete\Core\Page\Page::getTotalBlocksInArea() (0)

Anyone know how to do this?

Thanks
Dave

madesimplemedia
 
hutman replied on at Permalink Best Answer Reply
hutman
What you have there looks right, but it's only going to give you a count of the blocks in the area, if you are trying to get an array of the actual blocks in an area you will need to do

$inputArea = new Area("Main");
$blocks = $inputArea->getAreaBlocksArray($page);
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks, I have changed my code but I'm still seeing this in the logs:

Call to undefined method Concrete\Core\Area\Area::getTotalBlocksArray() (0)
hutman replied on at Permalink Reply
hutman
You need the code to be getAreaBlocksArray
madesimplemedia replied on at Permalink Reply
madesimplemedia
You're right, my bad.

Works great thank you very much :)