0

I have a problem with theme hook suggestion for language switcher block. I just need to place theme_links__locale_block() in MYMODULE.module file

My module:

/**
 * Implements hook_theme()
 */ 
function MYMODULE_theme() {
  return array(
    'MYMODULE_links' => array(
        'variables' => array(
            'links'      => NULL,
            'attributes' => NULL,
            'heading'    => NULL
        )
    )                                    
  );
}

/**
 * It doesn't work...
 */
function theme_MYMODULE__locale_block(&$variables) {
    // custom function code ...
}

It works in my template.php file:

function MYTHEME_links__locale_block(&$variables) {
    // custom function code ...
}

I don't want to leave it in template.php because it is a part of my module.

Any help would be appreciated.

0

SOLVED!

adding hook_theme_registry_alter(&$theme_registry) was the answer.

/**
 * Implements hook_theme_registry_alter
 * 
 */
function MYMODULE_theme_registry_alter(&$theme_registry) {

  $mod_path = drupal_get_path('module', 'MYMODULE');

  if (isset($theme_registry['links'])){ 
    $theme_registry['links__locale_block']['theme path'] = $mod_path;
    $theme_registry['links__locale_block']['function'] = 'MYMODULE_links';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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