Is there any way to call hook_entity_view() from a theme?

I tried adding the implementation to the template.php file, but the function is not called.

I know I can do it via custom module, but as it's a rather UI addition, it would make more sense to do through theme.



hook_entity_view() will only be invoked for modules so no chance of putting it in a theme unless you want to change how something works under the hood.

It's not a problem though, as all alter hooks are invoked for themes; so you can use hook_entity_view_alter() instead.

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete entity content structure has been built.

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.