0

I'm struggling with blocks and a custom module. What I've got so far is a module which generates a block with that code:

function commerce_bulk_invoice_block_info() {
    $blocks = array();
    $blocks['showinvoiceoptions'] = array(
        'info' => t('Define Invoice Options'),
    );
    return $blocks;
}
function commerce_bulk_invoice_block_view($block_name = '') {
    if ($block_name == 'showinvoiceoptions') {
        echo '<div id="invoice-block">';
        if(!isset($_SESSION['selected_entities'])) {
            echo 'select a product first';
        } else {
            echo '<h1>SESSION Variables:</h1>';
            echo '<pre>';
            print_r($_SESSION['selected_entities']);
            echo '</pre>';
        }
        echo '</div>';
    }
}

My problem is, the content generated by hook_block_view is not shown in the selected region but directly after the opening body tag. And it pulls the whole head-content into the body. Anyone knows a solution for that?

2

By the documentation, you should return content you want in block, not echo it.

$block['subject'] = t('Subject'); // String here
$block['content'] = t('Content'); // Array or string here
return $block;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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