Functions & methods:
Name | Description |
---|---|
phptemplate_init | Implementation of hook_init(). |
phptemplate_theme | Implementation of hook_theme(). |
Function Definitions:
/**
* @file
* Handles integration of PHP templates with the Drupal theme system.
*/
/**
* Implementation of hook_init().
*/
function phptemplate_init($template) {
$file = dirname($template->filename) .'/template.php';
if (file_exists($file)) {
include_once "./$file";
}
}
/**
* Implementation of hook_theme().
*/
function phptemplate_theme($existing, $type, $theme, $path) {
$templates = drupal_find_theme_functions($existing, array('phptemplate', $theme));
$templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
return $templates;
}
Purpose of phptemplate_init():
It is common function for all the themes in our enabled themes. If you
wish to include any php files like "template.php" or others, by using this
function we can achieve it.
Is it possible to rename the phptemplate.engine ?
Yes, we can rename the phptemplate.engine into our own naming like
manotemplate.engine. But the most important thing to link the renamed engine
name which needs to given in our Front end / Admin theme .info file.
Like,
name = Admintheme
description = Administration theme
screenshot = screenshot.png
engine = manotemplate
What are the information we can get in the hook_init()?
/** * Implementation of hook_init(). */ function manotemplate_init($template) { echo "<pre>"; print_r($
template
); echo "</pre>";
/* and other relevant code we can add in this function.. */
}
Sample Result:
stdClass Object ( [filename] => sites/all/themes/admintheme/admintheme.info [name] => admintheme [type] => theme [owner] => sites/all/themes/engines/manotemplate/manotemplate.engine [status] => 1 [throttle] => 0 [bootstrap] => 0 [schema_version] => -1 [weight] => 0 [info] => Array ( [name] => Admintheme [description] => Administration theme [screenshot] => sites/all/themes/admintheme/screenshot.png [engine] => manotemplate [stylesheets] => Array ( [all] => Array ( [style.css] => sites/all/themes/admintheme/style.css ) [print] => Array ( [print.css] => sites/all/themes/admintheme/print.css ) [screen] => Array ( [icons.css] => sites/all/themes/admintheme/icons.css ) ) [scripts] => Array ( [admintheme.js] => sites/all/themes/admintheme/admintheme.js [slider/slide.js] => sites/all/themes/admintheme/slider/slide.js ) [regions] => Array ( [admin_left] => Left sidebar [admin_right] => Right sidebar [content] => Content [header] => Header [footer] => Footer [dashboard_left] => Dashboard Left [dashboard_right] => Dashboard Right [slider] => Sliding region [slider_left] => Sliding region Left [slider_middle] => Sliding region Middle [slider_right] => Sliding region Right ) [core] => 6.x [settings] => Array ( [rootcandy_navigation_icons] => 0 [rootcandy_navigation_icons_size] => 24 [rootcandy_header_display] => 0 [rootcandy_navigation_custom_icons] => [rootcandy_dashboard_display] => 0 [rootcandy_dashboard_help] => left [rootcandy_dashboard_messages] => right [rootcandy_dashboard_content_display] => 0 [rootcandy_help_display] => 0 [rootcandy_hide_author] => 0 [rootcandy_hide_panel] => 0 [rootcandy_navigation_source_admin] => _rootcandy_default_navigation ) [version] => 6.x-1.8 [project] => rootcandy [datestamp] => 1275900908 [features] => Array ( [0] => comment_user_picture [1] => favicon [2] => mission [3] => logo [4] => name [5] => node_user_picture [6] => search [7] => slogan [8] => primary_links [9] => secondary_links ) [php] => 4.3.5 ) [stylesheets] => Array ( [all] => Array ( [style.css] => sites/all/themes/admintheme/style.css ) [print] => Array ( [print.css] => sites/all/themes/admintheme/print.css ) [screen] => Array ( [icons.css] => sites/all/themes/admintheme/icons.css ) ) [scripts] => Array ( [admintheme.js] => sites/all/themes/admintheme/admintheme.js [slider/slide.js] => sites/all/themes/admintheme/slider/slide.js ) [engine] => manotemplate )
By using this hook_init() we can do our own code to enable / disable
a new file etc..
No comments:
Post a Comment