Skip Navigation

[Resolved] Odd/Even styling using classic views

This thread is resolved. Here is a description of the problem and solution.

Problem:
Odd/Even styling using classic views

Solution:
Toolset view's shortcode [wpv-item] offers the attribute index and with index attribute you can define the odd or even.

You can find proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/odd-even-styling/#post-2227725

Relevant Documentation:
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-154400

This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by marioD-5 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2227241
oddeven.png

Hello,

I have a view (loop pasted below this message), that has 3 columns and I'd like to apply an odd/even class styling.
I added the desired effect in the attached screenshot.

-----------------
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<div class="container wpv-loop js-wpv-loop speakers_container">
<wpv-loop wrap="3" pad="true">
[wpv-item index=1]
<div class="row ">
<div class="col-md-4 speaker_odd">[wpv-post-body view_template="loop-item-in-view-speakers-in-an-event"]</div>
[wpv-item index=2]
<div class="col-md-4">[wpv-post-body view_template="loop-item-in-view-speakers-in-an-event"]</div>
[wpv-item index=3]
<div class="col-md-4">[wpv-post-body view_template="loop-item-in-view-speakers-in-an-event"]</div>
</div>
[wpv-item index=pad]
<div class="col-md-4"></div>
[wpv-item index=pad-last]
<div class="col-md-4"></div>
</div>
</wpv-loop>
</div>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No speakers found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
----------------------

#2227725

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset view's shortcode [wpv-item] offers the attribute index and with index attribute you can define the odd or even.

For example:

<wpv-loop>
    [wpv-item index=odd]
         add your content for odd index
    [wpv-item index=even]
         add your content for even index
       
 </wpv-loop>

More info:
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-154400

#2227761

Hi Minesh,

I got that part, but how can I still put them into a 3 columns layout?
Please check my code to see what I mean.

Thanks,

#2227803

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As you want to use the pad and wrap attribute with your loop.

You can add styling that you want to add for odd to the following:
- [wpv-item index=1]
- [wpv-item index=3]

And you can add the even styling to the following:
- [wpv-item index=2]

#2227861

Hi Minesh,

Please check the screenshot I attached in my initial question.
Your solution repeats the same pattern on each line:
1 = purple
2= red
3=purple

That's not exactly what I'm looking for.

Is there any other way you could think of?

Thanks for your assistance,

#2227865

Nevermind, I figured it out.
I changed wrap=6 and explicitly declared index 1 through 6.

My issue is resolved now. Thanks,

#2227873

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great - you are welcome to mark resolve this ticket.

#2227875

My issue is resolved now. Thank you!