Posted by yo2lux on July 3, 2008 at 4:10pm
I have this module:
<?php
/**
* @file
* Obtain forum statistics
*/
/**
* Implementation of hook_block()
*/
function forumstat_block($op = 'list', $delta = 0) {
switch ($op) {
case 'list':
$block[0]["info"] = t('Forum statistics');
return $block;
case 'view':
$item = _forumstat_fetch();
$subject = theme('forumstat_mytheme', 'Forum Statistics');
$content = theme('forumstat_mytheme', check_plain($item->nid));
$block["subject"] = $subject;
$block["content"] = $content;
return $block;
}
}
/**
* Fetching statistics from database
*/
function _forumstat_fetch() {
$sql = "SELECT nid FROM {node} WHERE status=1 AND type='forum' ORDER BY RAND() LIMIT 1";
$res = db_query($sql);
$item = db_fetch_object($res);
return $item;
}
/**
* Implementation of hook_theme()
*/
function forumstat_theme() {
return array(
'forumstat_mytheme' => array(
'template' => 'forumstat_mytheme',
'arguments' => array('forums' => NULL, 'text' => NULL),
),
);
}And this is my theme file (forumstat_mytheme.tpl.php):
<table width="100%" border="1">
<thead>
<tr>
<th><?php print $forums; ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php print $text; ?></td>
</tr>
</tbody>
</table>Now, someone know why drupal put the default block scheme in HTML ?
<div id="block-forumstat-0" class="block block-forumstat">
<h2></h2>
<div class="content"></div>
</div>I don't need the H2 element and the DIV CLASS="content" element. Why drupal put this in HTML, I use a separate "forumstat_mytheme.tpl.php" file for theming. Someone help me a bit ? Thanks!