Get list of current blocks

4 views
Skip to first unread message

FedericoMP

unread,
Feb 16, 2012, 12:17:30 PM2/16/12
to habari-users
I'm doing some modifications for K2 and I'm trying to create a new
default block. This block should be installed in the sidebar as soon
as the theme is activated.

How can I can know if the block is already in use the specific area?
I've found this:

$blocks = $this->get_blocks( 'nav', 0, $this );
if( count( $blocks ) == 0 ) {
$block = new Block( array(
'title' => _t( 'Charcoal Menu' ),
'type' => 'charcoal_menu',
) );

$block->add_to_area( 'nav' );
Session::notice( _t( 'Added Charcoal Menu block to Nav area.' ) );
}

But it just test if there are any other blocks in the area, not what
block are used.
Reply all
Reply to author
Forward
0 new messages