You must write your own module. In your module, you must define your theme using the hook_theme
function.
function mymodule_theme($existing, $type, $theme, $path) { return array( 'your_theme_key' => array( 'variables' => array( 'nid' => NULL, 'title' => NULL ), 'template' => 'your_template_filename',
After that, you should create the file your_template_filename.tpl.php
in the folder of your module, and in this file you will have the variables $nid
and $title
(in this example). Your template file will look like this:
// define your html code using variables provided by theme <div class="node node-type" id="node-<?php print $nid; ?>"> <h3><?php print l($title, "node/{$nid}"); ?></h3> </div>
After that, you can use your theme in any modules of your site. Should be called like this:
$variables = array( 'nid' => $nid, 'title' => $title ); $output = theme('your_theme_key', $variables); print $output;
source share