I have a Drupal module where I want to separate the html from the logic by placing it in a template file. You'd think this would be easy but I can't figure out how it's supposed to work within Drupal. When I google it I come upon massive guides on making Drupal themes or articles on focusing on a single aspect of the templating process. I downloaded and installed the Examples for Developers module which has a section for templating, but even that does not do exactly what I want and breaks as soon as I make any significant change.
I made a simple module called blob to try to get this to work. I have the following template file called blob-stuff.tpl.php:
<div class="container-inline">
Hi <?php print $myname; ?>
</div>
In blob.module I have
function blob_menu() {
$items['blob1'] = array(
'title' => 'Blob1',
'page callback' => 'blob_stuff',
'access arguments' => array('access content'),
);
return $items;
}
function blob_theme() {
return array(
'blob_stuff' => array(
'template' => 'blob-stuff',
),
);
}
function template_preprocess_blob_stuff(&$variables) {
$variables['myname']='Bob';
}
function blob_stuff(){
return 'Bob';
}
Which of course doesn't work, because at this point I'm just guessing.
Can anyone give me a simple, working example of this, following Drupal best practices?