By Drupalsky on
I am kind of new to Drupal. So please bear with me if this quesiton is obvious to you. I am using Drupal 6.20.
I have a node type called article (created via CCK). I am hoping to theme this node's form when creating content.
In my tests, function mytheme_node_form is able to get called, but function mytheme_article_node_form never gets called.
In each test, I used only one of the two functions. According to Drupal's, mytheme_article_node_form is a legitimate theming function and should get called.
Can anyone tell me why this happens? Did I miss something?
Best.
Comments
It seems like you have to
It seems like you have to register the theme function in hook_theme() something like
function mytheme_theme($existing, $type, $theme, $path) {
return array(
'article_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'article-node-form',
),
}
Then creare a template file called 'article-node-form.tpl.php' in your mytheme folder and clear the cache. Now you should be able to theme your form inside this template file.
Nodes are themed through
Nodes are themed through template files (node.tpl.php by default) and I do not believe you can change it to a function. You can though use node-article.tpl.php in your theme directory.
Actually he just wanted to
Actually he just wanted to theme the node_form instead of the completed node(view). According to his requirement "I am hoping to theme this node's form when creating content....". So that's the reason i have suggested the hook_theme() function. But if he just wanted to theme the finalized node output then your suggestion will work fine...
Got it working
The two functions mentioned above were defined and tested in my theme's template.php (a Zen's sub-theme).
I defined the hook as Nagarajan and Zen suggested as follows in template.php:
function mytheme_theme(&$existing, $type, $theme, $path) {
$hooks = zen_theme($existing, $type, $theme, $path);
$hooks['article_node_form'] = array('arguments' => array('form' => NULL) );
return $hooks;
}
Then the function mytheme_article_node_form got called!
However, I am still puzzled. According to Drupal's rule I know about, when I define a theming function such as 'article_node_form'
in [hook]_theme, I should expect theme_[hook function], which means theme_article_node_form gets called. Why does mytheme_article_node_form get called?
Thanks!