views:

45

answers:

1

How can I put li tags around every 2 results in drupal views?

I have this;

result1 
result2
result3
result4

And I need this;

<li> result1 result2 </li>
<li> result3 result4 </li>

Thanks

+1  A: 

In the template that loops through the results, you can make a counter and use that to add the li tags if needed. So if the counter is odd, add opening li tag in the start and if the counter is even, add the closing li tag.

googletorp
You might try looking at how the grid view template works, as it is capable of outputting two-column tables.
Grayside
+ 1 @Grayside: Good guess! @jdln: perhaps you want to make the view 2 columns and that is why you're wrapping it in an `<li>` this way? You can do that by selecting the `Style` setting in the view to `Grid`. Select 2 columns.
Sid NoParrots
I need 2 results per li tag as this is the format that jQuery Carousel needs. The grid style users a table so wont solve my problem. Thanks anyway.
jdln
@jdln Why do you want to wrap two results in one li tag? With jcarousel you can configure the amount of items scrolled.
googletorp
Because I need 2 columns (im using a vertical scroller). jcarousel calculates the scrollable height based on the height of all the items, so if I create 2 columns by editing the css I get blank scrolling. The scrollable area becomes twice as large as it should be.
jdln
I messaged the creator and he said the only way to have 1 columns was to have 2 items in each li.
jdln
I will probably actually use this scroller instead. However it also needs html around results; http://flowplayer.org/tools/demos/scrollable/vertical.htm
jdln
@jdln I see, well my answer still applies. You can find the template you need to overwrite in the theme information link in the view UI.
googletorp
So I need to write php to do this? I was hoping their would be some UI based way. Thanks
jdln
@jdln: The Drupal theming system relies much on PHP to loop through stuff etc in the templates. So it's just normal theming really and only a few lines of php code you need to add to the default template. Anytime you want to add logic, you'll have to use php.
googletorp
Ok. Thanks a lot, will look into this.
jdln