I've been trying to figure out this for the past few hours and I'm at a loss.
I created a new content type called "events" with two custom fields using CCK, date and location. I create a new event, fill in the title, date, location, and body information so now I have my first node that has the title, date, location, and body information all listed out.
How do I go about customizing how that data is output? What I mean by that is it simply lists out the information in a generic format like such:
----------------
Title
Date:
9/20/2008
Location:
Seattle, WA
Whatever I typed in the body here!
----------------
I know i can create a new tpl.php file called node-event.tpl.php to customize that particular node, but I'm not quite sure how I can customize how each field is output. I put in
print_r($node); to view all of the properties of the current $node object, and when I view the page I can see a lot of data and how it's broken down each field. However, I don't know how to interpret this data to break it down so I can have control over where each field is printed.
Hopefully this makes sense to someone. It's 5:28AM here and I need to sleep. ;)
Comments
Here is part of the print
Here is part of the print out from the
print_r($node);When I use
print $field_location[0];it simply prints out the word "Array".I wish I understood PHP. ;) I'm sure this is something simple.
contemplate
Check out the contemplate module, it will help you understand how it all works better.
For your immediate issue, what you want is
<?php print $node->field_location[0]['view'] ?>Figured it out... <?php
Figured it out...
print $field_location[0][value];You can use tpl.php files,
You can use tpl.php files, but there is also a module called http://drupal.org/project/contemplate that can help you.
It was written to solve YOUR specific problem.
Contemplate lets you customize the output of node teaser and full node display for any content type in Drupal.
BTW:
or possibly ...
Ah, I messed with that
Ah, I messed with that module before but never really took time to understand it! Awesome! Exactly what I needed. =)
Is there any way to theme blocks individually? I have one block I want to have a different table background color than the rest but it seems like all blocks are controlled in the stylesheet together. I'm not quite sure how you can specify a unique class to a particular block. I thought about editing the teaser view in the contemplate module but that only seems to let you modify what's in the block, and not the block itself.
Find out the #ID of the block DIV tag
Hi,
the easiest way I can think to do that would be to do a "view source" on one of your Drupal pages, take note of the ID of the div tag that wraps the block, then add some custom CSS rules to your theme for only that block.
Example:
The first block on my site has the following id and class (in the Drupal generated HTML):
id="block-block-1" class="clear-block block block-block"
In your style.css file, you could add a CSS rule:
div#block-block-1{
background: red;
}
div#block-block-2{
background: blue;
}