First, apologies if this should have been logged against CCK ...

I am using Drupal 6.4 / PHP 5.2.6 / MySQL 5.0.67

I am trying to theme a CCK input form called "front_page". So, first I copied garland theme into my all\themes folder and renamed it myGarland. Then, in template.php, I had the following functions:

function myGarland_theme() {
	return array(
		'contact_mail_page' => array(
			'arguments' => array('form' => NULL),
			//'template' => 'contact-mail-page',
		),
	);
	return array(
		'front_page_node_form' => array(
			'arguments' => array('form' => NULL),
			//'template' => 'front-page-node-form',
		),
	);
}
function myGarland_front_page_node_form($form) {
	$form['title']['#title'] = t('My title');
	$form['title']['#value'] = t('My value');

	$output = drupal_render($form['title']);
	return $output . drupal_render($form);

	return drupal_render($form);
}

That didn't work - so I tried leaving the //'template' => 'front-page-node-form', line uncommented and added a preprocess function as below:

function myGarland_preprocess_front_page_node_form(&$vars) {

	$vars['form']['title']['#title'] = t('My title');
	$vars['my_form'] = drupal_render($vars['form']);

}

And in my template file (filename: front-page-node-form.tpl.php from form_id), I've got:

<p>Theming cck forms ...</p>
<?php print $my_form; ?>

Didn't work either. I've gone through tutorials on the following pages (my thanks to the writers): http://drupal.org/theme-guide, http://blip.tv/file/1139104, http://blip.tv/file/1139210/ and http://11heavens.com/theming-the-contact-form-in-Drupal-6. In no particular order, found the information on all of these very useful and was able to theme the contact form following the steps from the tutorials, and that worked fine. Can anyone help please?

... and thanks

dantina.

CommentFileSizeAuthor
#3 theme_info.jpg22.88 KBdantina

Comments

dantina’s picture

Title: Unable to theme CCK content type » Unable to theme CCK content type - update

Further to this ...

Found some information on naming cck node templates and renamed the template to: node-front_page.tpl.php - but that didn't work either. However, when I viewed a content created using the "front_page" content type, I found just this on the page and nothing else!:

Theming the form ...

- which is the content of node-front_page.tpl.php. The actual content of the page seem to have been overwritten by the template file although I am no longer calling the file - and yes, I cleared the cache! Had to delete the file completely before I was able to see the content.

I am not sure I understand this behaviour, can anyone explain please? Why did the template file and or preprocess function etc., work for the contact form and not the cck content type form?

damien tournoud’s picture

Project: Drupal core » Content Construction Kit (CCK)
Version: 6.4 » 6.x-2.x-dev
Component: other » General

Reassigning to the CCK queue.

dantina’s picture

StatusFileSize
new22.88 KB

Here's a screenshot of my theming info ...

Chill35’s picture

So the theming function which is theming the form is theme_node_form().

dantina’s picture

Title: Unable to theme CCK content type - update » It would appear so, but ...

Hi Chill35,

It would appear so, but the question is: how can I create my custom theme template i.e. get the page to use my custom theme page - 'front-page-node-form'?

thanks,
dantina

Chill35’s picture

You do not need to register a theming function. One is already registered.

In the tutorial you saw, how we knew that no theming function was registered for the form was that it was themed using theme_form().
That's not the case here.

You need to follow these guidelines: http://drupal.org/node/173880. Look under "Converting from functions to templates".

dantina’s picture

Title: It would appear so, but ... » It would appear so ... now able to theme the view, but ...

Thanks Chill35.

I tried to follow the instructions on that page and other parts of the theme guide, but I must be doing something wrong because I can't seem to get the form to display properly. Found some useful instruction here for theming the view page: http://drupal.org/node/266817 (in case it helps anyone), so the view page is now looking great. But I am still unable to theme the CCK input form.

I'd like to be able to do this - and set the cck fields in a table - so if anyone can help, I'd be very grateful.

dantina.

kingandy’s picture

Title: It would appear so ... now able to theme the view, but ... » Unable to theme CCK content type

Changing issue title back to something meaningful. (Beware, that's not a "comment title" box! Entering a new title when you comment on an issue changes the title of the issue.)