Home ›
Altering path and theme path of template files in Drupal 7 is just for make-believe?Altering path and theme path of template files in Drupal 7 is just for make-believe?
Submitted by Benjamin Melançon on January 15, 2011 - 1:40pm
Update: Issue posted. http://drupal.org/node/1028214
The goal is to use the book-variable.tpl.php (exactly like the book-variable.tpl.php is used, including how it gets overridden by themes) but without its preprocess function. Here's one fallback approach that should work, but doesn't, due to seeming weirdness in Drupal:
<?php
function dgd7glue_theme() {
return array(
'dgd7glue_book_navigation' => array(
'variables' => array('book_link' => NULL),
'template' => 'book-navigation',
'path' => 'modules/book',
),
);
}
function
dgd7glue_theme_registry_alter($theme_registry) {
debug($theme_registry['book_navigation']);
$theme_registry['dgd7glue_book_navigation']['path'] = $theme_registry['book_navigation']['path'];
$theme_registry['dgd7glue_book_navigation']['theme path'] = $theme_registry['book_navigation']['theme path'];
debug($theme_registry['dgd7glue_book_navigation']);
}
function
template_preprocess_dgd7glue_book_navigation(&$variables, $hook) {
$book_link = $variables['book_link'];
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = 'dgd7glue-nextprev';
$variables['book_title'] = t('Suggestions');
$variables['book_url'] = 'suggestions';
$variables['current_depth'] = 0;
$variables['tree'] = '';
$variables['has_links'] = TRUE;
// ... more
}
?>
Well this is totally bogus. We can see the two debug functions, and see the paths are being set successfully to the same thing. But we can see from the undefined index error below them that the book-navigation.tpl.php in core, not the one in the theme overriding it, is being called!
* Debug: array ( 'template' => 'book-navigation', 'path' => 'sites/default/themes/apress/templates', 'type' => 'theme_engine', 'theme path' => 'sites/default/themes/apress', 'variables' => array ( 'book_link' => NULL, ), 'preprocess functions' => array ( 0 => 'template_preprocess', 1 => 'template_preprocess_book_navigation', 2 => 'contextual_preprocess', ), 'process functions' => array ( 0 => 'template_process', 1 => 'rdf_process', ), ) in dgd7glue_theme_registry_alter() (line 77 of /home/ben/code/dgd7/drupal/sites/default/modules/dgd7glue/dgd7glue.module). * Debug: array ( 'variables' => array ( 'book_link' => NULL, ), 'template' => 'book-navigation', 'path' => 'sites/default/themes/apress/templates', 'type' => 'module', 'theme path' => 'sites/default/themes/apress', 'preprocess functions' => array ( 0 => 'template_preprocess', 1 => 'template_preprocess_dgd7glue_book_navigation', 2 => 'contextual_preprocess', ), 'process functions' => array ( 0 => 'template_process', 1 => 'rdf_process', ), ) in dgd7glue_theme_registry_alter() (line 80 of /home/ben/code/dgd7/drupal/sites/default/modules/dgd7glue/dgd7glue.module). Error * Notice: Undefined variable: prev_url in include() (line 39 of /home/ben/code/dgd7/drupal/modules/book/book-navigation.tpl.php).
Searched words:
theme template path
Comments
Post new comment