My objective: get and change the breadcrumb within a custom module.

So it's possible that template_preprocess_HOOK is not even the best tool to be using for this, please mention that.

My question, though, is what HOOK to use? Should it be called template_preprocess_mymodule or template_preprocess_mytheme?

2 Answers 2


The HOOK corresponds to the theme function or template you are preprocessing.

If you wanted to alter page.tpl.php, you would use function MYTHEME_preprocess_page(&$variables).

If you wanted to alter theme_item_list(), you would use function MYTHEME_preprocess_item_list(&$variables).

A note, any dashes should be converted to underscores.

So views-view.tpl.php would be altered by function MYTHEME_preprocess_views_view(&$variables).

  • When I do that, I get WSOD. My function is called rescue_preprocess_views-view--testtaxo().
    – beth
    Jul 9, 2012 at 15:31
  • Check your PHP error log to find out what is causing the WSOD. It is possible you have a php syntax error within your preprocess function.
    – sheena_d
    Jul 9, 2012 at 15:42
  • 1
    your function name can't have -'s in it: PHP is thinking you are trying subtraction :)
    – Jimajamma
    Jul 9, 2012 at 15:45
  • The question was about using 'template_preprocess_HOOK()'. Dec 1, 2021 at 15:09

Assuming your template file for breadcrumb menu is my-breadcrumb.html.twig. So you can override variables in this template by defining template_preprocess_my_breadcrumb(&$variables) in a module.

Or you can also use MYTHEME_preprocess_my_breadcrumb(&$variables) in your YOUTHEME.theme

Your Answer

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

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