I've created a drupal module, it's info file, and a tpl.php for the block all in the same module directory. When I enable the module, I can see the block listed and assign it to a region. However when I view the page the block does not display. If I do a vardump on $content within block_view, the dump displays at the top of the page, and firebug shows that block is wrapped with the right div tags. I would think if you did a var dump on within the block_view function, it should display in the right region. This one is probably really simple, but it's got me stumped - any help much appreciated. Also if I title the block just to see if it shows up anywhere in the page - it's still nowhere to be seen even though admin shows it it in the region, and no filters are set to prevent it being viewed. I would think that if you gave the block a title -if it's on the page it would at least show a title even if everything else is blank.
module file:
function my_block_block_info() {
$blocks['my_block'] = array(
'info' => t('My Block')
);
return $blocks;
}
function my_block_block_view() {
if(arg(0) == 'node' && is_numeric(arg(1))) {
$id = arg(1);
}
$query = "SELECT * FROM table WHERE id= :id AND deleted=0";
$args = array(':id' => $id);
$result = db_query($query,$args)->fetchAll();
foreach($result as $item) {
$stuff[] = array($item->stuff_url,$item->stuff_name);
}
$content=
theme_render_template(drupal_get_path('module','my_module').'/'.'block-- my_block.tpl.php',array("stuff" => $stuffs));
return $content;
}
block--my_block_tpl.php
<div class="wrapper">
<?php
foreach($stuffs as $thing) {
for($i=0; $i < count(thing); $i++) {
//print out result passed from module
}
}
?>
</div>