Styling nodes content area

bpwilliams - July 25, 2008 - 20:13

I was wondering how i might be able to style the content area of a node. The node template i am working with is looking good except for the information contained in the $content. This node is a custom content type that i created, and it contains some fields that i added with the CCK module. The line in the node template

<div class="content"><?php print $content;?></div>

prints all my custom fields as well as the body. I would like to gain more control over this and add in some of my own markup so i can style them nicer. The node pages i have seen indicate that $content is not an array. Is there a way i can still print the individual parts that make up $content separately?

Hi Brian, If this code is

yuriy.babenko - July 25, 2008 - 22:29

Hi Brian,

If this code is from node.tpl.php, you can just do:

<?php
echo '<pre>';
print_r($node);
echo
'</pre>';
?>

to see all the data, including individual fields. Output what you need and comment out the print $content; statement.

You can also control which CCK fields are displayed by going to Edit Content Type -> Display Fields (link in the tabs).
---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials

contemplate

yelvington - July 25, 2008 - 22:39

Take a look at the contemplate module.

Any other alternatives than

giorgio79 - July 28, 2008 - 08:50

Any other alternatives than Contemplate and node.tpl.php?

I notice contemplate handles more or less the CCK fields but it is quite buggy, as some CCK fields do not appear.

Also, node.tpl.php seems quite manual :P

Was wondering if there are any alternatives? A node field layout editor maybe? Like panels for the entire page layour, sg for the content fields?

Are you familiar with CSS? and Firebug?

talyia - July 28, 2008 - 11:52

Brian,
I would just modify the CSS rules/styles for this. (Or add a new CSS rule as need be.)
Also, if you are not already using Firebug (an extension for Fox that you just cannot do without when developing your theme...) I would seriously take a look at it. This little web developer tool will help you see exactly what you need to write styles for.... or where exactly something is in the code.

Hope this is of some help,
Christine

Sure am

bpwilliams - July 28, 2008 - 13:15

Hello again Christine,
Yes I am very much familiar with both of them. While they can prove very useful, in this case I was wanting to add my own custom markup to the template file rather than using the markup generated by the print $content statement. Yuriy's suggestion of using the print_r($node) gave me the info that i needed to target only the elements I needed. Thanks for the suggestion anyways.
Brian

 
 

Drupal is a registered trademark of Dries Buytaert.