Skip Navigation

[Resolved] How to build a view from multiple repeating fields

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 3 replies, has 2 voices.

Last updated by Minesh 8 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2686347
Snipaste_2024-03-04_22-46-32.png
Snipaste_2024-03-04_22-43-01.png
Snipaste_2024-03-04_22-40-28.png
Snipaste_2024-03-04_22-39-57.png

I want to build something like a view - but with the contents taken from multiple repeating fields.

I have some custom types which include for example:
- teaser icons with 4 elements
- teaser headlines also with 4 elements
- teaster content with also 4 elements

Now I would like to create a grid/view that renders 4 blocks, each composed of the same index 0,1,2 or 3 of those different repeating fields:

icon[0] headline[0]
content[0|

icon[1] headline[1]
content[1|

and placed into a grid.

I attached some screenshots of the fields and how the current page online looks like.

Any help is really appreciated,

best regards,
Jan

#2686379

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Rather creating repeating field in this case - what if you create a repeating field group that will allow you to add the item in single row for all entities.

Please check the following Doc:
- https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/

Is that make sense to use repeating field group in your case?

#2686387

Hi Minesh,

thanks for your quick reply. Sadly the repeating fields are already created, as they come from a drupal import already - and I want to prevent editing all f them as there are about 1000 of them.

So still any help is really appreciated 🙂

#2686425

Minesh
Supporter

Languages: English (English )

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

What if you try to use the shortcode [wpv-for-each]:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each

Add the following shortcode to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_shortcode('wpv-index', function ($atts) {
  
    static $i = 0;

  if($atts['type']=='get'){
          $n = $i;
           return $n;
  }else if($atts['type']=='set') {
           $n = $i++;
}
});

For Example:

<ol>
[wpv-for-each field="wpcf-teaser-icons"]

<li>[types field="teaser-icons"][/types]</li> | [types field="teaser-link" index="[wpv-index type='get']"][/types]  | [types field="teaser-content" index="[wpv-index type='get']"][/types] </li> 

[wpv-index type='set']

[/wpv-for-each]
</ol>

Where:
- You can modify the field slugs as required.
- Please register the shortcode name wpv-index at:
=> Toolset => Settings => Front-end Content => Third-party shortcode arguments

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/shortcodes-within-shortcodes/#third-party-shortcode-arguments

Can you please try and check if the above solution help you to resolve your issue.