I'm not sure how to word my question as I'm unclear exactly how Drupal works. I've only had two weeks to study and implement it here: http://pi.ilovedogs.com. Eventually, however, I'd like to get into module development as I find Drupal very interesting..just not enough time to complete this particular project.
* What I'm trying to do (based on my understanding of Drupal): create a unique look for each node type. I've read a lot of material that talks about modifying the template.php and adding a hook function to catch and modify the node variables before they get passed onto rendering. I'm supposed to be returning the variable array to the node-.tpl.php file. I'm not sure how I can do that for more than one node type because it seems I can only overwrite that theme function once.
** I'm trying to accomplish the following (you may need to look at the website to understand what I'm trying to explain):
1. In the Featured article section (at the very top in an ugly green), I want to be able to write an article and also attach (in an extra field) photo, which won't be displayed at all in the node but rather used strictly as a background on the front page.
2. In the News section (on front page), I want those nodes to have a small thumbnail picture to the left of each article ("news" content type"). Check out http://pi.ilovedogs.com/files/images/ilovesdogs2b.jpg for an idea of what I mean.
I've done most everything throw views and I've tried modify a block-views-.tpl.php..but that only works for one article (as in Nutrition and Training). I'm thinking that I needed to modify each node type....hence finally leading me here because I don't know how to put it all together.
There's more to this list of things to do but I think if I can figure out how this (questions presented here) works (logically or code-wise), then I could proceed to do the rest on my own.
In a haste, I've gone through a lot of nicklewis.org's tutorials (starting with nicklewis.org/node/841) and Drupals' own documentation (drupal.org/node/11811)..I have these memorized. But maybe I'm just going about it all wrong. I need direction or some tips. Maybe there's more I can read somewhere else but right now, 1+1 != 2 for me. I can't put it all together. Perhaps I'm trying to customize too much? Please advise!
Comments
I think this is what you are after.
Say you have content types 'article', 'news' and 'dogs'. They are easy to apply different looks to by first copying node.tpl.php to node-article.tpl.php and node-news.tpl.php and node-dogs.tpl.php. You should now have one file per content type of the form node-{type}.tpl.php. You can find the default variables avaible for each of these templates under Node.tpl.php in the handbook (they are treated as node.tpl.php by the theme engine).
As for "1. In the Featured article section (at the very top in an ugly green), I want to be able to write an article and also attach (in an extra field) photo, which won't be displayed at all in the node but rather used strictly as a background on the front page." that will probably require a little code. If it was me I would use the nodeapi hook that looks for a featured article with an attached image and if found generates a little inline css that sets the image as the background image of the body tag.
Got that, sorta
Hey, thanks for the quick response.
First note, the JPG URL above is wrong. Extra 's'. Should be http://pi.ilovedogs.com/files/images/ilovedogs2b.jpg.
So yeah, I do have a node-{type}.tpl.php for each content type that I have. However, the variables I wanted to access have already been "processed" into $content. So that's why I figured I could separate those variables and modify them first. I'm not sure how to access those variables. I know there's no clean way to do it in Drupal and that I'd have to code a bit, which I don't mind. I just don't know what to write or where because I guess I'm still unclear how it all runs together. And if I do add that theme function in template.php, it'll affect all nodes. Is this my only choice - to affect all nodes and just stick with it?
Hopefully, I was clear...
Look at $node
$node node is available in the template and contains the unprocessed values, for debugging you can add to template
which will show you all the available fields.
I'm assuming "$node node is
I'm assuming "$node node is available in the template" means in the template.php, right? Sorry if it seems like a dumb question because I consider node.tpl.php a template file too..
So based on what you are saying, by modifying the template.php file: I will affect ALL node.tpl.php (and variant types)?
Yeah, I learned about the print_r() early on and found it to be utterly valuable.
Sorry by template I meant
Sorry by template I meant node.tpl.php or one of it's variations
Figured it out
Hey, I waited it out. Bought the Drupal Pro Dev book. Read almost all of it. Went to BADCamp 07 in Berkeley and got my answer. Just needed to customize CCK. Thanks though!