Get first block in area, then get that blocks data
Permalink 1 user found helpful$blocks = Page::getCurrentPage()->getBlocks('Main'); foreach($blocks as $b) { var_dump($b->bID); // returns the ID of the blocks in area }
The code above works and lists each blocks ID in the area "Main". I need to get the "title" data of the first block. Title being one of the options of the block.
I am assuming it's something like:
$b = Block::getByID($blocks[0]->bID) var_dump($b->title);
The above doesn't work however.
Any help is appreciated.
This is how to get the first block in an area and then retrieve it's details. The block in question has a title property as set when adding it:
Hope this helps someone else.