Services

  • Drupal CMS Developer
  • Website speed optimisation
  • Drupal 6 to Drupal 8 migrations

Welcome

Welcome, I am a Web Developer based in Madrid, Spain originally from the UK. I studied Computer Science & eBusiness at Loughborough University. I specialise in Content Management System websites

Drupal 6 override theme for a page in a module

This is actually quite simple. Lets say you want to override the admin theme only when creating a new node of type TYPEX

<?php
/**
* Instance of hook_init().
*/
function MYMODULENAME_init() {
  global
$custom_theme;
 
 
// Get the theme settings
 
$theme_default = variable_get('theme_default', 'garland');
 
$admin_theme = variable_get('admin_theme', 'garland');
 
 
//Override theme when creating new TYPEX nodes
 
if(arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'TYPEX')
  {
   
$custom_theme = $theme_default;
  }
 
//Keep the normal admin theme for all node add/edit/clone
 
elseif((arg(0) == 'node' && arg(2) == 'clone') || arg(0) == 'admin' || (arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) {
   
$custom_theme = $admin_theme;
  }
 
//Normal theme for normal pages
 
else
  {
   
$custom_theme = $theme_default;
  }
}
?>