2

I'm trying to create a module that creates a block to a specific region so I use this module on multiple sites instead of using the admin menu copy and pasting creating blocks with HTML code in it and putting it in the region that I want it to be.

Somehow the block doesn't even shows up in the blocks admin section. Maybe I'm overlooking something but I quite sure my code is correct for the hooks implemented below:

/**
 * Implements hook_block_info()
 */
function bannert_block_info() {
    $blocks['bannert'] = array(
        'info' => t('bannert'),
        'cache' => DRUPAL_CACHE_PER_PAGE,
        'region' => 'three_33_third',
        'status' => 1,
    );

    return $blocks;
}

/**
 * Implements hook_bock_view()
 */
function bannert_block_view(){
    $block['subject'] = t('');
    $block['content'] = _bannert_get_bannert();

    return $block;
}

/**
 * get banner 
 */
function _bannert_get_bannert() {
    return include_once('banner.html');
}

The only thing I'm doubting about is the _bannert_get_bannert() function but that doesn't prevent the block from being created, now does it?

I'm getting this error now:

Warning: Cannot use a scalar value as an array in _block_get_renderable_array() (line 346 of /Users/Jack/Sites/drupal-7/modules/block/block.module). Fatal error: Unsupported operand types in /Users/Jack/Sites/drupal-7/modules/block/block.module on line 352

1 Answer 1

2

I changed the _banner_get_bannert() code to the following one:

function _bannert_get_bannert() {
    return "<div>push me</div>";
}

The error is gone, and the block is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.