Skip Navigation

[Resolved] Testing index=other for gt a certain value

This support ticket is created 4 years 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 1 reply, has 2 voices.

Last updated by Minesh 4 years ago.

Assisted by: Minesh.

Author
Posts
#1918491

Seeing as there is no index gt n function, I created a snippet to return the output row number
----------------
add_shortcode( 'loop', 'loop');
function loop( ){
global $loop_n;
if ( !isset( $loop_n ) ) {
$loop_n = 0;
return $loop_n;
}
$loop_n++;
return $loop_n;
};

which works fine as [loop] after <wpv-loop> in my view (outputs the row number)

however, the following does not work (the first conditional does not output vvv)
-----------------
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-item index=0]
[wpv-item index=other][loop]
[wpv-conditional if="( '[loop]' gt '0') "] vvv [/wpv-conditional]
[wpv-conditional if="( $(wpcf-range) gt '0') "]
------------
thanks for your help

#1918537

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Toolset Views/Blocks offers the shortcode [wpv-loop-index] that will return the current loop index within the views loop.
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-loop-index

You can use this shortcode in conjunction with [wpv-conditional] shortcode.

For example:

[wpv-conditional if="( '[wpv-loop-index accumulate='false' pad='false' offset='-1']' gt '0') "] 
vvv 
[/wpv-conditional]

Can you please try above code and try to resolve your issue.