use hook_nodeapi instead of hook_init+arg() checks
Pasqualle - September 17, 2008 - 23:05
| Project: | Theme setter |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | minor |
| Assigned: | Stalski |
| Status: | postponed |
Jump to:
Description
is it possible to change the theme inside hook_nodeapi? because that could be cleaner. you do not have to search for the node type..
function theme_setter_nodeapi(&$node, $op, $teaser, $page) {
if (arg(0) == 'node') {
_theme_setter_change_theme_by_node_type($node->type);
}
}
#1
This is tested in earlier versions and did not give the proper result. The problem is that you have to do this algoritm as soon as possible in the bootstrap process.
That is why the hook_init was found the only place where i had no bugs at all enforcing a theme.
Nevertheless i plan on going on to see if the code could be cleaned up in such a way as you describe.
Your reaction is true, but I feel the same way. So far I could not get it working through hook_nodeapi because it is too late to change the global config variable. You can change it! But drupal has already used it for some parts of the theming.
Exampe of a bug I had : the center part was shown in the correct frontend theme , but the header , logo anvatar, css etc ... was still garland. Not a pretty view :)
#2