Monday, April 25, 2011

Theme a CCK input form in Drupal 6

In my template.php file I've this:

function myadmintheme_theme(&$existing, $type, $theme, $path) {
  return array(
    'node_form' => array(
     'arguments' => array('form' => NULL),
     'template' => 'ccktype',
    ),
  );
}

And I've a ccktype.tpl.php in the same dir:

<b>works!</b>

But is not working, if I enter to node/add/ccktype I don't get the "works!" message.. I tried everything!

any help would be appreciated

From stackoverflow
  • First of all, see that Drupal's not caching your module. Go to Administer > Site Configuration > Performance, and clear all caches.

    If that doesn't work, try renaming the file to node-add-ccktype.tpl.php.

    br1 : thanks, but is not work... it's strange, isn't it?
    Seb : Yeah, I really don't know... I had problems with that theme hook as well. Sorry I can't help anymore :(
  • The theme function you need to override is ccktype_node_form, not node_form. All node forms maintained by the node module get mapped to the node_form function for building, but they still have unique form ids.

    br1 : I tried that also, but didn't work. I forgot to say that in the "Administration theme" y check "Use administration theme for content editing" (that is obvious).
    br1 : hey, I didn't notice this, but there is a very little change in the style when I use ccktype_node_form :D It is not printing "WORKS!", but is better than nothing ;D
    br1 : hey, now works! I love you!!! xD
  • This is the solution:

    function myadmintheme_theme($existing, $type, $theme, $path) {
      return array(
        'ccktype_node_form' => array(
         'arguments' => array('form' => NULL),
         'template' => 'ccktype',
        ),
      );
    }
    

    thanks a lot Eaton!

    Seb : Glad you solved this! If Eaton helped you, then please mark his answer as correct; that will help others find this problem is solved and will grant Eaton reputation points for having helped. :)
  • Thanks so much for this! I spent a ton of time looking on the stupid Drupal site and tried about 20 things that didn't work.

    Ugh!

0 comments:

Post a Comment