views:

827

answers:

3

I would like to have two different displays of a node teaser depending on where it is on the site.

Changing the .tpl of the block alone is not good enough because I need to have a separate imagecache image displayed.

Are there ways to have another display type added? Or change what fields a node display type recieves (ie: the imagecache image displayed)?

+1  A: 

It might not be the most elegant solution, but I think you could achieve this by using a combination of CCK and Views.

  • Use CCK to add another field to your content type, one that contains your alternative teaser text.
  • Then, use Views to create the list of nodes where you want the alternative teaser to show up. Include your new teaser field in the view, add some formatting, and you're done.

If you have complex formatting needs, you could try this trick and write a specific .tpl.php file to present the view.

Bevan
A: 

I'm a little confused about what you're doing. You say node teaser, and then you mention a block.tpl. Are you already using Views? How are you displaying this node in a block? How do you define where these different places are on the site?

You can control imagecache presets, teaser length, etc. through views but it would be helpful to get a bit more information on what's displaying where.

stephthegeek
+1  A: 

As others have pointed out, it's a little unclear what you're doing, but it sounds like your using a node view to create a block and then using the block template to markup the contents of the block. The key contents of such a block will be generated by the node template. The default node template determines its markup based on a $teaser variable set to TRUE or FALSE. The value of $teaser is based on the full node/teaser distinction in views. That's obviously a boolean variable, so there's no third option. So the answer to your specific question is no, you can't do that.

That said, you can accomplish the goal of 3 (or more) different displays by introducing your own variables in template_preprocess_node based on context indicators such as arg() or $view->name, and then using those variables in your own node template (or more likely node type template) to control output markup. You can then apply different imagecache presets by calling the imagecache theme function, something like:

<?php print theme('imagecache', 'thumbnail', $node->field_image[0]['filepath']); ?>

That's a lot to learn if this is all new to you, hopefully not too overwhelming.

Scott Reynen
Thank you! This both answers my original question and solves my imagecache problem! I guess its not possible to add another display type that will be recognized by Views and CCK. Oh well, modifying .tpl and preprocessing will accomplish the result with a little effort! Thanks!
Douglas

related questions