Skip Navigation

[Resolved] Transfer number of loop items from view to parent content template

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

Problem:

How can I get the number of photos out of the view and make it available to the content template?

Solution:

There isn't such a built-in feature, but as a workaround, you can move those HTML codes into your post view "fotos-per-parent". for example:

https://toolset.com/forums/topic/transfer-number-of-loop-items-from-view-to-parent-content-template/#post-1235375

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-no-items-found

This support ticket is created 5 years, 8 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 2 replies, has 2 voices.

Last updated by roulartaM 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1235092
detail.png

I have a post type called 'shops'. That post type have a repeatable field: 'photos'. To display those photo's in de content template, I created a view that loops through the photo's related to the post type.

In my content template, I want to check if there are related photo's or not. The reason why: the photo's should take 5 lines in the bootstrap grid system and the other shop information should take 7 lines in the bootstrap grid system. If there are no photo's at all, the shop information should take 12 lines instead.

How can I get the number of photos out of the view and make it available to the content template? Or if this isn't possible: how can I make it work in another way?

Thx a lot for helping!

#1235375

Hello,

There isn't such a built-in feature, but as a workaround, you can move those HTML codes into your post view "fotos-per-parent". for example,

Edit post view "fotos-per-parent", in section "Loop Editor":
- within shortcode [wpv-items-found] ... [/wpv-items-found], display the shop information in 12 lines.
- within shortcode [wpv-no-items-found] ... [wpv-no-items-found]. display shop information in 5 + 7 lines

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-no-items-found

#1235494

I moved the code out of the content template and pasted it in my view. It works like that, thanks!