1

I'm trying to output views and i'm using 960gs as well.

It possible to enable views processing so views knows if it this is the last one of the row and that way i can add a class "alpha" to the first view out put and "omega" to the 4th item and last item?

Update: Looking for primarly a php solution; not a jquery one; as it's not best practice to utilize javascript to manipulate layouts (IMHO).

2

The contributed Semantic Views module has the option of adding first and/or last class attributes. Pretty snazzy solution since you can also use it to specify better html elements at the same time!

1

if you does not recieve answers that help from backend perspective, I am sure that you can solve this from jquery perspective:

Jquery select first and last divs from a list of items: https://stackoverflow.com/questions/3328076/jquery-select-first-and-last-divs-from-a-list-of-items

For instance this set of divs (also is possible with li, a, etc..):

<div class="item">qwe</div>
<div class="item">asd</div>
<div class="item">zxc</div>
<div class="item">ghj</div>
<div class="item">bnm</div>

with Jquery you can select first and last item, in this case, to add a class to first/last target elements (put this in the end of your view results template):

<script>
$('.item')
    .eq(0).addClass('first').end()
    .eq(-1).addClass('last').end();
</script>

of course you must have respective class to this different elements, for instance:

<style type="text/css">
.first, .last{
background-color:#0099FF;
}
</style>

and here is the result:

enter image description here

this is another example: Addressing first/last item in an ul, li: https://stackoverflow.com/questions/5680032/addressing-first-last-item-in-an-ul-li

I hope information be useful.

  • Good point there @moon.watcher . Trying to avoid requiring javascript to manipulate layout. I'll give you a +1 anyways; but looking for merely a php solution. – chrisjlee Oct 6 '11 at 4:53
  • yes, I agree about avoid manipulation of layout using javascript. Altough I think that Jquery has an good crossbrowser compatibility in lots of cases (its my humble opinion) and you can try/research/build alternatives to achive low consuption of resources of your scripts. Of course I can be wrong – cigotete Oct 6 '11 at 5:51
0

Discovered that this is answer is still being worked on by the community. It's been a long-standing problem with views.

There's a issue queue node here: http://drupal.org/node/1188216

Hopefully, there will be a patch for this eventually.

As for now; I've found refuge in display suite for certain contexts and semantic views plugin

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.