Skip Navigation

[Resolved] Incremental row numbers in Views

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.

Tagged: 

This topic contains 6 replies, has 5 voices.

Last updated by masino.sinaga 8 years, 9 months ago.

Assigned support staff: Caridad.

Author
Posts
#31041

Dear support!

I'm wondering if it is possible to insert incremental row numbers to the table generated by the View, so that line numbers be 1, 2, 3 ... Something that would work like an auto-increment field?

Thank you in advance

#31061

Dear Kirill,

Add these lines to functions.php in your theme folder:

add_shortcode('incrementor', 'incrementor');
function incrementor() {
static $i = 1;
return $i ++;
}

Then define your View template as:

<wpv-loop>
<li class="container[incrementor]"> <li>
</wpv-loop>

Please let me know if there is anything else that I can assist you with.

Regards,
Caridad

#32256

Thank you Caridad!
Never have thought I can do it this way, than you for the suggestion.

#59895

I am trying this out but its not working

<wpv-loop>

[wpv-if i="[incrementor]l" evaluate="$i == 1"]
Design Template 1
[/wpv-if]

[wpv-if i="[incrementor]l" evaluate="$i > 1"]
Design Template 2
[/wpv-if]

</wpv-loop>

How do i do this correctly? I have already included the shortcode function in my function

#69553

Hi Roville,

I try to make exactly the same thing of you.... without success for now.

Do you find a solution or maybe ideas to test with you ?

Thanks in advance,
Regards

#69666

Hi again, it's ok for me now.

Adriano give me another solution here https://toolset.com/forums/topic/isolate-the-first-result-of-a-view/

So I see that with a shorcode with attribute (we take each field with attribute) it's could be possible to make that you want Roville. It's complex but seems possible !

Regards

#512101

Thank you, Caridad! I've just found out this solution from your answer above.