Displaying CCK fields content using code in template.php
rusdvl - October 21, 2009 - 22:23
Hi,
I've been googling for a couple of hours but cant seem to find the answer... either i cant find it or i just dont understand it....
I am overriding a function in my template.php file that a module is creating. The function outputs a list of the content from a particular content type. So it displays the title, body and author of all the nodes in that content type. I've added a few CCK fields to that content type and now need to make that function display those extra fields. Fields like address and image. How do I do that?
Also the image is being resized and cropped into a thumbnail using imagecache so I would like to use the thumbnail as a display.
Can anyone help me with this?
Thanks ahead.

Contemplate module
I was able to get custom CCK fields to display in the manner I wanted without the use of a template.php file. I used the Contemplate module ( http://drupal.org/project/contemplate ) and with a good read of its documentation and some trial and error, got comfortable with creating fairly pleasing, theme independent layouts of custom fields, including imagecache versions of image fields.
thanks, but I need to know
thanks, but I need to know how to do it in template.php, as there are some fields that the function is outputting that I dont need and I've removed. So now I need to add the new cck fields that I created.
You have that type of control
You have that type of control in Contemplate
You have that type of control
You have that type of control in Contemplate
I've installed it and it
I've installed it and it seems to only modify the node display of that content. I need to modify the display of a list of the nodes within that content type. Something similar to when you see a list of blogs posted. So several blog post in a list. This is similar.
In the template.php file ive
In the template.php file ive printed this code: $ad->field_price[0]['view'] and when I look at it through devel it shows me the exact value of that. BUT it does not display it... doesnt print it onto the screen... any ideas?
Its definitely there if I go by what devel says. Man this is annoying... someone please help....!!!
This is the whole function:
function theme_ed_classified_category_list_ad_row($ad, $rowcount) {module_load_include('inc', 'ed_classified', 'ed_classified_utils');
$content .= '<li';
if ($ad->sticky) {
$content .= ' class="sticky"';
}
$content .= ">\n";
$content .= theme('imagecache', 'thumbnail', $field_photos[0]['filepath']);
$content .= '<h3>'. l($ad->title, drupal_get_path_alias('node/'. $ad->nid),
array('attributes' => array('title' => 'Description here!'))) ."</h3>";
if (_ed_classified_variable_get('show_body_in_ad_list', EDI_CLASSIFIED_VAR_DEF_SHOW_BODY_IN_AD_LIST)) {
$content .= '<div class=\'classified-description\'>'. check_markup($ad->body, $ad->format, FALSE) .'</div>';
if (theme_get_setting('toggle_node_info_'. $ad->type)) {
$content .= '<div class="field-address"><label class="label-field-address-value">'.t('Address:').' </label><span class="field-address-value">'.$ad->field_address[0]['view'].'</span></div>';
$content .= '<div class="field-price"><label class="label-field-price-value">'.t('Price:').' </label><span class="field-price-value">'.$ad->field_price[0]['view'].'</span></div>';
}
}
$content .= "</li>\n";
return $content;
}
UPDATE: Figured it out... $ad->field_price[0]['view'] should've been $ad->field_price[0]['value']