Skip Navigation

[Resolved] Insert row in the middle of the Grid

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

Problem:

In the view block, I have a 2 column, 20 row Grid on a Template and I need to inser a row after row 5.

Solution:

There isn't such kind of built-in feature within Views in blocks editor, you might consider custom codes, for example:

https://toolset.com/forums/topic/insert-row-in-the-middle-of-the-grid/#post-2215489

Relevant Documentation:

This support ticket is created 3 years, 2 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by igorL-3 3 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2212949

Tell us what you are trying to do? I have a 2 column, 20 row Grid on a Template and I need to inser a row after row 5. I can clear all the rows after 5 and add another row at the bottom but then I will need to re-do the rows I've cleared. Is there an easier way. I know that a item like a grid can be moved up or down but how to do it within the grid.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2213459

Hello,

With Views loop, you can get current item index with shortcode [wpv-loop-index accumulate="false" pad="false"]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-loop-index

And you can use above shortcode in Toolset conditional block, check it's value, and display what you want, for example:

[wpv-conditional if="  ( ( '[wpv-loop-index  accumulate="false" pad="false"]' eq '11' ) ) "]
Here insert something
[/wpv-conditional ]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-conditional

#2213731
Screenshot 2021-11-05 at 12.02.27.jpg

That doesn’t make a lot of sense to me. I don’t have a table in the VIEW I have a grid, as per attached image, on the content template using block editor.
The picture is showing a blank grid with only one row. I have 20 rows that are all populated with items I’m displaying. But I need to have another item displayed in row 5.

#2215489

There isn't such kind of built-in feature within Views in blocks editor, you might consider custom codes, for example:
1) create a HTML div tag, with CSS class name "insert-this", and display the row you want to insert
2) Use JS codes to move above HTML div tag after the 10th item of view's loop, like this:

jQuery( document ).ready(function() {
   jQuery( 'div.insert-this' ).insertAfter( 'div.tb-grid-column:nth-of-type(10)' );
});
#2216631

My issue is resolved now. Thank you!