You ll use the drupal theming system because you want to seperate presentation from logic.
The possibilities
A simple theme function like in drupal 5
In drupal6 when adding a new theme function you need to flush the cache so drupal will rebuild its theming registry. (admin/settings/performance near the end push the clear cache button) You should install http://drupal.org/project/admin_menu [1] it has a clear cache link too. And it is just a very handy module to administer your site.
<?php
function tandem_misc_theme() {
return array(
'sponser_link' => array(
'arguments' => array('link' => NULL),
),
);
}
?>
<?php
function theme_sponser_link($link) {
return check_url($link);
}
?>
<?php
function phptemplate_sponsor_link($link) {
$link = '<a href="http://ietsanders';
">http://ietsanders';
</a> return $link;
}
?>
How to use a preprocess function and a template file?
<?php
function tandem_misc_theme() {
return array(
'sponser_link' => array(
'template' => 'sponser_link',
'arguments' => array('link' => NULL),
),
);
}
?>
<?php
//tpl file
print check_url($link);
?>
<?php
function phptemplate_preprocess_sponser_link(&$variables) {
$variables['link'] = '<a href="http://somethingelse.com';
">http://somethingelse.com';
</a> $variables['another_link'] = '<a href="http://somethingotherthatelse.com';
">http://somethingotherthatelse.com';
</a>}
?>
For more read http://drupal.org/node/165706 [3] and the hook_theme api documentation http://api.drupal.org/api/function/hook_theme/6 [2]
Links
[1] http://drupal.org/project/admin_menu
[2] http://api.drupal.org/api/function/hook_theme/6
[3] http://drupal.org/node/165706