Hi Everyone -

Am trying to theme my first view - a series of teasers in a block. Have been through the documentation and the dojo and am confused about what stuff goes where. I get the impression from what I've read that theming teasers is supposed to be easy, but I'm missing a few key pieces of puzzle that people just seem to know.

For example, it is written that by using the print_r($node) function, I can get a lot of info. Where would I put this? template.php, specific-block.tpl.php? What would need to surround it for it to work? Once I get the addressable variables, where do I put these?

What determines where the bits and pieces that surround the teaser go? I've themed the teaser the way I want it to show up in contemplate, but Drupal adds all this stuff I want to get rid of. Where is it coming from and how do I override it?

I would be unbelievably grateful for any help I can get.

Comments

webslinger23’s picture

There is no need to go into your template.php file.

Copy the node.tpl.php file in your theme folder. Name it node-nodetype.tpl.php.
Example: node-blog.tpl.php.

Copy and delete the contents of the file. (If you lose the contents, you can always copy from node.tpl.php.)

For the teaser, do the following if statement:

<?php if ($teaser): ?>

Paste the contents here. Remove node links and whatever else you don't want to see in the teaser view. Whatever you want surrounding your teaser node, whether it's in views or other kind of teaser list, put it around the <?php print $content?> statement.

<?php else: ?>

Paste the original code here or whatever you want to surround your node in a full node view.

<?php endif; ?>

Of course, you can get all complicated with it, but for 99% of all the teaser views, this is all you'll need to do.

If you've figured out Contemplate, then understand what you've built there becomes the $content variable in the node template files.

You can put the <?php print_r($node)?> statement right in the node template as well and it will show all your variables and what they're holding for that particular node. It's a lot like the available variables sections in Contemplate.

weke’s picture

I´ve done all of this, but the teaser just looks the same. I´ve even tried without any node.tpl file in the theme folder, but the result is the same. Any good ideas about this?

I guess my website belongs to the 1% of the exceptions to the rule...