Wednesday 23 March 2011

Drupal 6 Template

Example from wysiwyg module

/**
* Implementation of hook_theme().
*
* @see drupal_common_theme(), common.inc
* @see template_preprocess_page(), theme.inc
*/
function wysiwyg_theme() {
return array(
'wysiwyg_profile_overview' => array(
'arguments' => array('form' => NULL),
),
'wysiwyg_admin_button_table' => array(
'arguments' => array('form' => NULL),
),
'wysiwyg_dialog_page' => array(
'arguments' => array('content' => NULL, 'show_messages' => TRUE),
'file' => 'wysiwyg.dialog.inc',
'template' => 'wysiwyg-dialog-page',
),
);
}

in wysiwyg.dialog.inc

echo theme('wysiwyg_dialog_page', $callback($instance));


/**
* Template preprocess function for theme_wysiwyg_dialog_page().
*
* @see wysiwyg_dialog()
* @see wysiwyg-dialog-page.tpl.php
* @see template_preprocess()
*/
function template_preprocess_wysiwyg_dialog_page(&$variables) {
// Construct page title
$head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
//code process here
}

in file wysiwyg-dialog-page.tpl.php
you can ouput any variable processed in template function
example


This make you able to customize layout for any page, menu on your site
cheer

No comments:

Post a Comment