I would like to create different templates for different nodes, but I cannot see any hook suggestion with theme debug. This is the template from quiz module. So in theme debug it looks like that:

<!-- THEME DEBUG -->
<!-- CALL: theme('multichoice_alternative') -->
<!-- BEGIN OUTPUT from 'sites/all/modules/contrib/quiz/question_types/multichoice/theme/multichoice-alternative.tpl.php' -->

I was searching for the right answer, reading about template suggestions, trying different things, but without any luck so far. I know, that I can create custom template for the whole block, but is it possible to create that custom template for the element which doesn't have any hook suggestions? Thanks!

1 Answer 1


You can do it this way

  1. implement hook_theme_registry_alter like the following:

     * Implements hook_theme_registry_alter().
    function YourCostumModuleName_theme_registry_alter(&$theme_registry) {
      // Defined path to the current module.
      $module_path = drupal_get_path('module', 'YourCostumModuleName') . "/templates";
      // Find all .tpl.php files in this module's folder recursively.
      $template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
      // Iterate through all found template file objects.
      foreach ($template_file_objects as $key => $template_file_object) {
        // If the template has not already been overridden by a theme.
        if (!isset($theme_registry[$key]['theme path']) || !preg_match('#/themes/#', $theme_registry[$key]['theme path'])) {
          // Alter the theme path and template elements.
          $theme_registry[$key]['theme path'] = $module_path;
          $theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
          $theme_registry[$key]['type'] = 'module';

  1. Create Folder called templates inside your custom module folder.
  2. Copy contrib/quiz/question_types/multichoice/theme/multichoice-alternative.tpl.php file into templates folder with the same name multichoice-alternative.tpl.php.
  3. Clear Cache.
  4. Now you have $form and $fullOptions variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.