Posted by bdawg8569 on July 25, 2008 at 8:13pm
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?
Comments
Hi Brian, If this code is
Hi Brian,
If this code is from node.tpl.php, you can just do:
<?phpecho '<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
---
Yuriy Babenko
http://yuriybabenko.com
My Drupal tutorials: http://yuriybabenko.com/blog/tag/tutorials
contemplate
Take a look at the contemplate module.
Any other alternatives than
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?
****Me and Drupal :)****
Clickbank IPN - Sell online or create a membership site with the largest affiliate network!
Review Critical - One of my sites
Are you familiar with CSS? and Firebug?
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
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
http://bri-space.com - Drupal information and more