1

I'm trying to override Calendar module's theme functions. Specifically, I'm trying to override template_preprocess_calendar_month() and template_preprocess_calendar_mini().

The override seems to work, but the problem is that the variables are processed/modified by template_preprocess_calendar_month() and template_preprocess_calendar_mini() before they reach the functions I implemented.

I need access to some of the theme variables before they are processed. Is there a way to do so?

1

You can create your own custom module and define your own copies of these preprocess functions.

For this example we'll call your module mysite.

In your mysite.module file you would define:

mysite_preprocess_calendar_mini(&$variables)
mysite_preprocess_calendar_month(&$variables)

And then modify the contents of the variables in these functions as needed. Copying the existing preprocess functions might be a good place to start if you're not sure what you want to modify.

Check out the preprocess documentation for some more information about how this system works.

  • template_preprocess_calendar_mini() is always executed before any implementation of hook_preprocess_calendar_mini(); there isn't the need to copy the code of template_preprocess_calendar_mini(). – kiamlaluno Dec 18 '12 at 8:54
1

You cannot, since template_preprocess_calendar_month() is executed before mytheme_preprocess_calendar_month(), assuming that mytheme is the machine name of the theme you implemented.

The order of execution of those functions is described in the documentation for theme(), which shows the following order, where MODULE is the machine name of any enabled module, ENGINE is the machine name of the theme engine used, and THEME is the machine name of the theme used to render the page.

  • template_preprocess(&$variables, $hook)
  • template_preprocess_HOOK(&$variables)
  • MODULE_preprocess(&$variables, $hook)
  • MODULE_preprocess_HOOK(&$variables)
  • ENGINE_engine_preprocess(&$variables, $hook)
  • ENGINE_engine_preprocess_HOOK(&$variables)
  • THEME_preprocess(&$variables, $hook)
  • THEME_preprocess_HOOK(&$variables)
0

It may help to play with the modules weight (execution order). Switching the execution order of the custom module and the calendar module might help.

The order may be changed at the system table (e.g. update system set weight = -10 where name='mymodule') , or via the modules_weight module.

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.