1

I am trying to place some hooks, but I don't even think they are being called.

THEMENAME_menu_alter(&$items)

and

THEMENAME_user_view_access($account)

are the hooks I am placing in my template.php file. However, they don't seem to be reacting to it. And yes, I am converting the dummy THEMENAME placeholder to the name of my theme in use.

But my real question is: are these hooks just for use in Custom Modules? Or can they be called in from template.php too?

If its just for custom modules then I guess that would explain why it's not reacting. But even so how is one suppose to know if a certain hook is only for a module or not?

P.S: I have also tried clearing the cache several times.

  • hook_menu and such hooks has to be in a custom module. For all theme functions and preprocess functions, you definitely can implement them in a theme, but most hooks won't work in a template. – AyeshK Apr 21 '14 at 0:17
  • Looks at the function names - module_implements,... – AyeshK Apr 21 '14 at 0:18
2

By Default you can consider all hooks can be extendible using custom modules...

Hook Documentation says

Hooks are how modules can interact with the core code of Drupal. They make it possible for a module to define new urls and pages within the site (hook_menu), to add content to pages (hook_block, hook_footer, etc.), to set up custom database tables (hook_schema), and more.

In template.php you can override functions which are exposed by hook_theme or functions like theme_*

There exists a good documentation that explains which functions you can override using template.php..

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.