1

I have a custom module created in Drupal 7 and I want it to display some HTML content. Here is how I have did.

But it is not working, what I do wrong?

<?php

/**
 * Implements hook_block_info().
 */
function submenus_block_info() {
    $blocks = array();

    $blocks['info'] = array(
        'info' => t('The submenu zone')
    );

    return $blocks;
}

/**
 * Implements hook_block_view().
 *
 */
function submenus_block_view($delta = '') {
    $block = array();
    $users = "edf";
    $title = "sdfsd";
    $block['subject'] = t('Submenu');
    $block['content'] = theme('submenus_output', array('users' => $users, 'title' => $title));
        return $block;
}

/**
 * Implement hook_theme()
 */
function submenus_theme() {
    return array(
        'submenus_output' => array(
            'variables' => array('users' => NULL, 'title' => NULL),
        ),
    );
}

/**
 * Display output
 */
function theme_submenus_output($somearray) {
    $content = '<div>TEST</div>';

    return $content;
}

?>
radu c
  • 4,138
  • 7
  • 30
  • 45

1 Answers1

1

I checked, there is nothing wrong with that code: the new block is available in the list of blocks, and if you assign it to a region, the block is called and the code from the custom theme function is displayed.


So you could try these things:

  • in Administration > Configuration > Development > Performance, clear the caches

  • in Administration > Structure > Blocks, make sure the block is assigned to a region that exists (such as "Content") and if it is, click the "Configure" link to see if there is a filter that prevents it from being displayed.

wildpeaks
  • 7,273
  • 2
  • 30
  • 35
  • Thanks man, the problem was in clear the caches. However now is displayed twice, I will check for it. – radu c Mar 02 '11 at 13:57