3

My goal is to have three views of a teaser.

Why different teasers? I have a blog and I'm displaying teasers of the blog entries in different ways because my pages have different layouts for the content.

Here's what my node-blog.tpl.php file looks like

<?php if(isset($node->teaser) && $node->teaser != ''): ?>
    <?php if ($is_front): ?>
        my code for the teaser on homepage
    <?php elseif ?>

        This is where I need help, I'm trying to have two different teaser views on the same page.

    <?php else: ?>
        all other teasers for blog will have this code
    <?php endif; ?>
<?php else: ?>
    this is the code for the actually blog page.
<?php endif; ?>

If this code didn't help, I'm trying to have it setup like this: Front page = Teaser 1 Blog page (featured) = Teaser 2 Blog page (lower section) = Teaser 3

I would normally create a new view but I'd like to have the code "unformatted" with my custom teaser code.

2 Answers 2

3

The Display Suite Module will allow you to create more custom build modes/view modes. So you can have teaser, teaser-foo, teaser-bar...

2
  • I'll install and check this out now, it might be the answer to my question. If I get it working, I'll post an example. Thanks!
    – Curtis
    Commented Jul 1, 2011 at 23:32
  • This worked great! Display Suite even comes with amazing documentation (unlike a lot of other modules I've used of of the box). Awesome PHP examples for DS are here: drupal.org/node/1098068
    – Curtis
    Commented Jul 2, 2011 at 4:58
0

View can be used to define multiple layouts of a single type of content with different displays.

In different teasers you might be using different different content information (fields), different length of text, different styles and orientations.

Add three or more displays (for each teaser), Manage your fields for each. Make sure to override settings which are different among displays. User theme information to select a suitable and most relevant to your display.

You can easily manage different displays (of block type) in regions.

1
  • I've got two problems with this solutions. 1.) I don't like all the extra Divs and tags that are generated when using views and fields. My code goes from being one line to 10 and I find it very messy. 2.) Second is the fact that I like everything hardcoded. I've had too many hosting issues in the past. My blog is growing and changing all the time. It's a must for hard code.
    – Curtis
    Commented Jul 1, 2011 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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