Get list of blocks on a page

Permalink
Is there a way to get a list of blocks that are on a page from a block controller ? I have a group of similar blocks that each add meta tags to the html head. I only want the first block on the page of this group to add these meta tags.

Or is there a way some how to check if these meta tags have been added to the page from a block's controller ?

warish
 
rge replied on at Permalink Reply
Here is an example:
https://www.concrete5.org/community/forums/customizing_c5/get-first-...

You can trie this:
<?php 
namespace Concrete\Package\Name\Block\Name;
use \Concrete\Core\Block\BlockController;
use \page;
defined('C5_EXECUTE') or die(_("Access Denied.")); 
class Controller extends BlockController
{
    public function view()
    {
        $blocks = Page::getCurrentPage()->getBlocks('main-content');
        foreach ($blocks as $b) {
            if($b->btHandle === 'accordion'){
                echo $b->bID;  
                break;
            }


After this you can also get an instance of the block.
Block::getByID($bID, $page, $areaHandle);