0

I want to add a Body class to my Node Add pages and my Node Edit Pages.

How can I do this?

I know that I need use the following in template.php to add a class to Node Edit:

function MYTHEME_preprocess_html(&$variables) {
     if (arg(0)=='node' && arg(2)=='edit') {
      $variables['classes_array'][] = 'node-edit-page';
    }
}

But how can I modify the code to work with node add?

Note: Node Add is when you create a node (e.g. yousite.com/node/add/page).

Node Edit is when you edit an existing page (e.g. yousite.com/node/1/edit)

1

Did you try :

function MYTHEME_preprocess_html(&$variables) {
  if ((arg(0)=='node' && arg(2)=='edit') || (arg(0) == 'node') && (arg(1) == 'add')) {
    $variables['classes_array'][] = 'node-edit-page';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.