Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In a project I'm working on I needed to differentiate between node types - I wanted some of the node types forms to appear in the default theme and some to appear in the admin theme.
I didn't want to add the capability to the module itself so i thought a better solution will be to add a drupal_alter function that other modules can manipulate it.
Then if a module want to force the admin theme it implements something like this:
function MY_MODULE_admin_condition_alter(&$data) {
if (SOME_CONDITION) {
$data['MY_MODULE'] = FORCE_ADMIN_THEME;
}
}
And if a module want to force the default theme it uses something like:
function MY_MODULE_admin_condition_alter(&$data) {
if (SOME_CONDITION) {
$data['MY_MODULE'] = FORCE_DEFAULT_THEME;
}
}
Comment | File | Size | Author |
---|---|---|---|
admin.module.diff | 935 bytes | gavri |