(P.S. I just have to accept the fact that no-one is ever ever ever ever ever ever ever ever going to answer my question at http://drupal.org/node/310397 so I am posting it again now in this post, worded differently. Perhaps my original question sounded too complicated in my other post? :)

All I would like to know is what I need to do, so that the first item in a views list is more prominent (displayed slightly differently) than all the items underneath. I know it must be very simple as I see it done on a bunch of websites but I just don't know how to do it.

Take a look at the following examples:
http://www.thecitizen.com/~citizen0/taxonomy/term/4
(Here the first 3 items in the list, or the ones that are stickied, have a larger headline & a byline, etc.)

http://www.themesnap.com/theme-demos/publisher-theme/node
(feature blocks #2 and #3 display an image thumbnail teaser and several titles of similar stories underneath. Thus the first item in the list/block differs from the items underneath.)

Could someone point me in the general direction at least? I understand how to work w Views/CCK, etc. So is this done primarily in Views?

Thanks a lot in advance for your help:)

Christine

Comments

marcvangend’s picture

I have been asking myself the same question a couple of times, but I never really had to do it. I think the best option would be to override the theme function for your view and add a class to the first item. There may be more solutions though - I'd like to read them!

Mark Theunissen’s picture

In Views 2, this is easy. Each View has a .tpl.php template file, and you can make a copy in your theme directory and edit it to your heart's content!

e.g. views-view-list.tpl.php

<?php
// $Id: views-view-list.tpl.php,v 1.2 2008/06/03 22:21:42 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */
?>
<div class="item-list">
  <?php if (!empty($title)) : ?>
    <h3><?php print $title; ?></h3>
  <?php endif; ?>
  <<?php print $options['type']; ?>>
    <?php foreach ($rows as $row): ?>
      <li><?php print $row ?></li>
    <?php endforeach; ?>
  </<?php print $options['type']; ?>>
</div>

Hope that helps!

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

talyia’s picture

Thank you SO MUCH:))

Then I suppose I could add some stuff in there to accommodate for items that are "stickies".
Such as

<?php if ($sticky): ?>
  (whatever I want to put in here)
  <?php endif; ?>

Since I am a newbie with writing php (but am a pro at moving someone else's code around until things work;) I am sure I can just use another tpl.php file as a cheat sheet to get the code I need. But this definitely points me in the right direction, so THANK YOU very much:)))

Christine

Mark Theunissen’s picture

Hey no problem ;)

Just check out the various templates in that folder (in the Views 2 'theme' folder or whatever it's called). Each one should hopefully be commented with details of the variables that are available to use. Just check... you should have access to each $node, and therefore to $node->sticky (or something like that).

Good luck!

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

Anonymous’s picture

hi

I don't understand how to use this code, Is there anybody can point me the way

Mark Theunissen’s picture

http://views.doc.logrus.com/group__views__templates.html

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

jumoke’s picture

Great tut. Thanks

nicl’s picture

See this mustardseed media video about theming views - very useful.,

http://www.mustardseedmedia.com/podcast/episode23