Search code examples
phpdrupaltemplatesdrupal-6preprocessor

How can I theme the template for edit or add a node for a specific content type?


I want to theme the template for edit or add a node for a specific content type.
For example, to theme all the content type forms I use the file page-node-{add|edit}.tpl.php (depending what I need to do add or edit).

But I didn't found the template name for a custom node type, for example Products.

I need to theme only for Products, but not for the other content types.

I've tried with page-node-edit-product.tpl.php and page-node-product-edit.tpl.php but no luck.


Solution

  • Hmm. There may be a better way but what about a preprocess function.

    I'm still really new to Drupal, so I would maybe try something like this [code may not work]:

    <?php
    function themeName_preprocess_page(&$vars, $hook) {
      if ((arg(0) == 'node') && (arg(1) == 'add' && arg(2) == 'product')) {
        $vars['template_files'][] =  'page-node-add-product';
      }
    }
    ?>
    

    Be sure to clear cache and theme registry after making new preprocess functions.