2

I need to build a "News" block on a website that shows teasers of certain categories.

BUT I cannot use teaser views because I don't want the styles that are in a teaser view. This rules out the viewsnodefield module and teaser option available in the first page of view creation.

My question is: how to reproduce a teaser using fields? How do I get the teaser content? How can I rewrite the link by surrounding the url link field?

Thank you for your thoughts

4

You can use Display suite and Views to achieve the required functionality. Using Display suite, you can control what fields appear in the teaser. Also, Display suite provides views Integration, so you can use your new teaser to show up in views. This article explains more about this.

3

Rather than reproduce the teaser, you could use the Entity View Mode module to create a new view mode for your node type (alongside Default/Teaser). You could then set that up with exactly the same field layout as the teaser view mode, and use your new view mode for the display in your View, instead of teaser.

The CSS classes generated shouldn't contain teaser-... so the content can be styled separately.

  • Thank you very much. Your answer was useful, it was easier for me with display suite – znat Apr 24 '12 at 9:46
0

You could implement hook_entity_info_alter in a custom module, define a new view mode, and then use this in your view instead of fields. This is a decent tutorial on them, but the basics are to define the new view mode:

function mymodule_entity_info_alter (&$entity_info)
{
  $entity_info['node']['view modes']['abridged'] = array(
    'label' => t('Abridged'),
    'custom settings' => TRUE,
  );
}

Then your new view mode shows up on the Manage Display tab for your content types. Set up the view mode as you wish. Then, in your view, choose Node row style, and pick your new view mode. Combine this with a template_preprocess_node, and you get a lot of flexibility. Once I stated dong this, I pretty much stopped using individual fields in views, except for the simplest things.

  • Anyone care to explain the downvote? Is there something factually wrong about this? – mpdonadio Apr 24 '12 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.