I want to add some custom checks to all of my Drupal pages (except the administration pages).

I am using Bartik theme that comes with Drupal 7.26

I added the custom check in node.tpl.php and the check worked for all urls of type /node/%
However, I also want to add this check for node add, edit and delete pages. I cannot do this.

What I have already tried:
-> Creating a node--add.tpl.php in bartik folder and adding check there.
-> Creating a custom module, and using hook_menu to route /node/%/id to a custom page.
-> Adding this function

function bartik_preprocess_page(&$vars, $hook) {
  if ((arg(0) == 'node') && (arg(1) == 'add' && arg(2) == 'product')) {
    $vars['template_files'][] =  'node-add-product';

in my bartik template.php file. After adding this function I created node-add-product.tpl.php file and added check there.

For all the methods I have tried, the node creation page does not change at all.

I also tried creating page--node--add.tpl.php. Then the custom check works. But the header, footer, and sidebars disappears. (Only node creation template is rendered)

1 Answer 1


I think you are using the wrong tpl file to edit the node/add/[content-type] form.

You need to create (if I remember correctly) a [content-type]-node-form.tpl.php and add the required elements you wish from there. See here for more details:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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