So, i was trying to do something weird (use the book-variable.tpl.php without its preprocess function). This approach should have worked, but doesn't, due to seeming weirdness in Drupal.

The path needs to be defined originally for it to work. Fine. I figured i was smarter than Drupal, i'll swap out the path with the path that we can see, in the theme registry, that the original book-navigation tpl has been made to use by the theme.

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'];
  $variables['book_id'] = 'dgd7glue-nextprev';
  // ... more
}

We can see the two debug functions, and see the paths are being set successfully to the same thing. But it is still using book-navigation.tpl.php in core, not the one in the theme overriding it.

        'path' => 'sites/default/themes/apress/templates',
        'theme path' => 'sites/default/themes/apress',

in dgd7glue_theme_registry_alter() (line 77 of /home/ben/code/dgd7/drupal/sites/default/modules/dgd7glue/dgd7glue.module).

        'path' => 'sites/default/themes/apress/templates',
        'theme path' => 'sites/default/themes/apress',

in dgd7glue_theme_registry_alter() (line 80 of /home/ben/code/dgd7/drupal/sites/default/modules/dgd7glue/dgd7glue.module).

But, this is the file getting used: modules/book/book-navigation.tpl.php

(Posted separately, the full debug statements and less temperate language.)

Comments

mlncn’s picture

Err, i'm pretty sure my problem is a duplicate of #342350: Override template files based on template filename as well as hook name but i'd like someone else to confirm.

dvessel’s picture

Status: Active » Closed (duplicate)

You're correct. That is your problem.