简体   繁体   中英

Drupal Block not showing on the page

$blocks['onemore'] = array(
'info' => t('onemore'),
'status' => TRUE,
'region' => 'content',
'weight' => 0,
'cache' => DRUPAL_NO_CACHE,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'admin/structure/nodequeue/1/view/1',   
 );

Problem - The above block shows up and works perfectly and as expected at 'admin/structure/nodequeue/1/view/1'

My problem is that I need to declare dynamic amounts of blocks based on the users inputs. So I wrote a db fetch and for each loop. If I do this then the block shows up in 'admin/modules' but the it is not in 'content' region for the seven theme. As I want to show it there.

I have double checked the values and even the admin/structure/block/manage/xdmp/onemore/configure has the value but the region is not selected.

I am assuming there is some conflict in the for each loop or the db query. Please advice your thoughts on it.

function xdmp_block_info() {
$blocks = array();
// Here we are going to do a db query so that I can get a list of 
// block ids to declare
$resultxdmp = db_query("
SELECT * FROM xdmp_container_list ");


foreach($resultxdmp as $resultRecords)
{    
$xdmp_nodeque_id_to_display =(int)$resultRecords->xdmp_nodequeue_id;
$xdmp_nodeque_id_to_display = intval($xdmp_nodeque_id_to_display);

$xdmp_path_to_show_block = 'admin/structure/nodequeue/'.$xdmp_nodeque_id_to_display.'
/view/'.$xdmp_nodeque_id_to_display.'';


$xdmp_machinenameofblock=(string)$resultRecords->xdmp_container_machine_name;
$xdmp_nameofblock=(string)$resultRecords->xdmp_container_name;



$blocks[$xdmp_machinenameofblock] = array(
'info' => t($xdmp_nameofblock),
'status' => TRUE,
'region' => 'content',
'weight' => 0,
'cache' => DRUPAL_NO_CACHE,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => $xdmp_path_to_show_block,   
);

  } // end for for each 

return $blocks;
}

cheers, Vishal

Are you sure the 'content' region is valid? If it's not, it of course can't show up :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM