During a cron run, I have a module that will cache the markup for many nodes. My problem is that during this cron run, any markup from the render function won't go through my themes hooks or templates.
From within my module code, how can I select the theme? Is there a hook? Is there a function where I can specify it?
Ultimately, I want to be able to do this and get the same results as if I were running this on a page_build hook:
render(node_view($node, 'teaser'));
render(node_view($node, 'mini_teaser'));
Drupal 7 has a hook that allows a module to change the currently enabled theme: hook_custom_theme().
Notice that the code used to invoke that hook is the following one. (See menu_get_custom_theme().)
Since the System module implements that hook, if you implement
hook_custom_theme()in a module for which the hook is executed first (e.g. the short name of the module is custom_module), then the System module could override the theme set by your module.Generally, setting the global
$custom_themeshould get the same effect. Be sure the theme being set is enabled.