I am reading "Drupal 7 Module Development", and I followed the book's steps to create a block in my module.
/**
* Implements hook_block_info().
*/
function first_block_hook_info() {
$block = array();
$block['list_modules'] = array(
'info' => t('A listing of all the enable modules'),
'cache' => DRUPAL_NO_CACHE
);
return $block;
}
/**
* Implements hook_block_view()
*/
function first_block_view($block_name ='') {
if ($block_name == 'list_modules') {
$list = module_list();
$theme_args = array('items' => $list, 'type' => 'ol');
$content = theme('item_list', $theme_args);
$block = array(
'subject' => t('Enable modules'),
'content' => $content
);
return $block;
}
}
first_block_view($block_name = '')
is using if ($block_name == 'list_modules')
to check which block should be rendered, but I think Drupal will only send list_modules' to my module.
Is there any need to check the block name in hook_block_view()
?