Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Content Construction Kit content types can be themed in several ways. Basic instructions are in the file README.txt in the CCK module directory. The other pages in this section include some other theming tips and tricks.
Comments
Some notes on theming node-content_example.tpl.php
Some notes on theming node-content_example.tpl.php, as an alternative to theming individual field.tpl.php files, can be found on Agaric Design.
[UPDATE: In Drupal 5, with CCK in core, you drop the "
content
" and can usenode-example.tpl.php
. ALSO:print $node->content['body']['#value'];
to get what it is in the body "field," as in Drupal 5 the regular node body is used-- but that's the precise way to get it out.](I'll try to clean it up and turn it into a handbook page when I'm not running a one-and-a-half night sleep deficit.)
~ben
People Who Give a Damn :: http://pwgd.org/ :: Building the infrastructure of a network for everyone
Agaric Design Collective :: http://AgaricDesign.com/ :: Open Source Web Development
benjamin, Agaric
CCK themeing in Drupal 5
In Drupal 5 with CCK module installed and activated, you just define your content type, then create a node-contenttype.tpl.php file to render the nodes for that content (replace "contenttype" in the filename by the "machine readable" content type name you gave while creating the type).
To access your customized fields within the template using $fieldname[0][value] where fieldname is the "machine readable" fielde name you provided while creating the field.
Note: Don't use the $content variable in your tpl.php file, it contains the default CCK rendering you wont need.
That's all.
Rainer
Professional Drupal services for Germany
http://www.feike.biz
Use View not Value
In studying use of CCK fields in themes, I have read that a template should refer to $fieldname[0][view] not $fieldname[0][value]. The 'value' is the raw data, and the 'view' is the data prepared for presentation by Drupal and CCK. I'm not sure exactly of the differences.
HAJ
Deffinitely do not use raw data
I believe the difference is what the raw data has not been processed by the input filters. Drupal has a policy of not removing offending content (unsanctioned html or external references), but just filtering it before displaying it. The value has the raw data and the view has the filtered version.
How to get the custom node title on Drupal 5
Thanks, Benjamin, the way to get the custom node body is
$node->content['body']['#value'];
indeed.I'd like to save time to some of you, guys, trying to figure out how to get the second predefined custom node field - title.
So,
<?php print $title;?>
- works<?php print $node->title;?>
- works<?php print $node->content['title']['#value']; ?>
- does not worksHmm, $node->content['title']['#value'] does not work, while $node->content['body']['#value'] does....
Jacob.
P.S. tested on Drupal 5.3
And Vice-Versa...
I have come accross this same problem Jacob but the other way around:
print $node->content['body']['#value'];
- worksprint $body;
- gives you everything within the node - i.e. is the same asprint $content
print $node->body;
- as with $bodyAnd I thought my tpl file wasn't even working!
Tested in 5.3
Tom
No delete & cancel button when trying to delete a page
Hi guys,
So, I'm using
print $node->content['body']['#value']
and it works great for my purposes.However, when I click on the edit tab and then scroll to the bottom and click on the Delete button to delete a page, I get the confirmation message "Are you sure you want to delete _page_title_". But, there is no Delete and Cancel button to confirm the delete.
It shows up when I use
print $content
.Any help is appreciated! Thanks!
-Tim
I have this problem too
I have this problem too. My guess is that it's just because the delete button is not located in the body section of the content - there must be another section to add to the template. Does anyone know what's missing?
Does this: <?php if
Does this:
Thanks for the suggestion
Thanks for the suggestion, unfortunately it doesn't seem to have any effect in my case.
Can anyone tell me what the pieces that make up $content are called, and/or where I would look for a complete list of them?
Output CCK fields as a table instead of divs
Pass the function the node object and it'll return the cck fields in a table.
The function sits in template.php
You can call it from node.tpl.php like
DT