Remove unnecessary CSS in Drupal 6 & 7

add the function to the template.php file in your theme folder


Drupal 6

function mytheme_preprocess_page(&$vars){
 $css = $vars['css'];
//core modules
//theme css

 $vars['styles'] = drupal_get_css($css);


Drupal 7


function mymodule_css_alter(&$css) {
  $exclude = array(
   'modules/system/maintenance.css' => FALSE,
    'sites/all/modules/contrib/module/module.css' => FALSE,
    'sites/all/modules/custom/module/module.css' => FALSE,
    'sites/all/themes/mytheme/mytheme.css' => FALSE,
  $css = array_diff_key($css, $exclude);

Creating a custom form from a module in Drupal 6


This will check if the user has permissions to view the form

function myform_perm() {
  return array('access myform content');


What url will lead us to the form, useful to start it with ‘admin’ so non-admin users can’t access it.

function myform_menu() {
  $items = array();
  $items['path/to/my/form'] = array(
    'title' => t('My Form'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('myform_form'),
    'access arguments' => array('access myform content'),
    'type' => MENU_NORMAL_ITEM,
  return $items;


function myform_form() {
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#required' => TRUE,
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send')
  return $form;


function myForm_validate($node, &$form) {
  if (isset($node->end) && isset($node->start)) {
    if ($node->start > $node->end) {
      form_set_error('time', t('An event may not end before it starts.'));

How to force a Webform to be an admin page (Drupal 6)

I’ve created a WebForm and I’ve been modifying it with hook_form_alter inside a custom module. Another thing I wanted to do is make the page be an admin page, I did changed the path to ‘admin/mypath’ but it didn’t worked.The solution I’ve come with is divided in two parts:

1- Show the admin theme

function mymodule_init(){
$path = drupal_get_path_alias($_GET['q']);
 if($path == 'admin/mypath'){
 global $custom_theme;
 $custom_theme = variable_get('admin_theme', '0');
 drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');

2- Restrict the access

function mymodule_nodeapi (&$node, $op){ 
// Load the currently logged in user. 
global $user; 
if($node->path == 'admin/mypath' && $op == 'view'){
 // Check if the user has the 'ATD Staff' role.
 else if (in_array('my_allowed_role', $user->roles)) {

No need to say, if somebody has a better solution please write a comment here.