Theming CCK Input Form
Last modified: June 30, 2008 - 23:37
Suppose you create new CCK content type called: product. You can alter how CCK displays content by creating node-product.tpl.php file. Now, how to alter the INPUT FORM?
Drupal's FormAPI will always look for a theme function based on the form id. In the case of node/add or node/edit forms, this id is type_node_form. So you can use the theme override like so:
<?php
function phptemplate_product_node_form($form) {
global $user;
$vars = array('user' => $user, 'form' => $form);
return _phptemplate_callback('product_edit', $vars);
}
?>You can also go further in making really designer-friendly tpl.php files by doing your drupal_renders in template.php like so:
<?php
function phptemplate_product_node_form($form) {
global $user;
$vars = array('user' => $user, 'form' => $form);
$vars['title'] = drupal_render($form['title']);
$vars['body'] = drupal_render($form['body_filter']);
// etc
return _phptemplate_callback('product_edit', $vars);
}
?>This will let you have a product_edit.tpl.php like:
<div class="intro">Start your product here</div>
<div class="title"><?php print $title; ?></div>
<div class="body"><?php print $body; ?></div>Finally, for maximal control, you can unset the FormAPI #title attributes and label your form elements directly in the template file:
<?php
function phptemplate_product_node_form($form) {
global $user;
$vars = array('user' => $user, 'form' => $form);
unset($form['title']['#title']);
$vars['title'] = drupal_render($form['title']);
unset($form['body_filter']['body']['#title']);
$vars['body'] = drupal_render($form['body_filter']);
// etc
return _phptemplate_callback('product_edit', $vars);
}
?>
How about D6 and CCK2?
How about D6 and CCK2?
Help with D6 please
Could use a few pointers!
Is it in a book somewhere? Is that what is going on?
Theme Individual CCK 2 Fields
Source: http://drupal.org/node/269319#comment-1184661
cck input theming!
i was wondering whether someone has better documentation about that...i would really appreciate a relevant more accurate post.
-----------------------------------------------------------------------------------------
Some people say the glass is half-full while others say its half-empty....i say bottoms up.
Additional info
http://drupal.org/node/101092