Home › Toolset Professional Support › [Resolved] Creating a front-end template for a repeating field group?
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Tagged: Views plugin
This topic contains 16 replies, has 2 voices.
Last updated by josephC-5 5 years, 3 months ago.
Assisted by: Shane.
Hi there,
I know it's possible to associate a front-end template with a single post and with an archive of a post type. Is it possible to create a template for a repeating field group? Or do I need to dip into the WP template hierarchy and create a properly named PHP file? The hierarchy I'm after looks like this:
list of artists (thumbnail grid, one image per artist) > list of a specific artist's artwork (thumbnail grid, one image per artwork) > multiple images of a specific artwork (one or more full-size images)
It's the last component (which uses a repeating field group) that I'm struggling with.
Thank you!
Saul
Hi Joseph,
Can you confirm my initial post about wanting to display the Repeatable field groups using views?
Please let me know.
Thanks,
Shane
Shane,
I *could* display the repeatable field groups using views, or not. I'm aware that even if I created a PHP template file, I can use shortcodes to insert views. Does that make sense? I'm not entirely sure what you're asking.
Saul
Hi Saul,
I'm Simply asking if its just the display of the Repeatable field groups on the frontend you want to do
I'm aware that even if I created a PHP template file, I can use shortcodes to insert views
Yes this is possible to do. You won't even need to use the shortcode because we have a function that can load the view from your php template.
Thanks,
Shane
Shane,
Yes, I'm just trying to display the repeatable field groups on the front-end. That said, I know how to do this through a view. What I want is a *separate page* (or template file, if needed) to display the repeatable field group.
Does that make sense? I can share annotated mockups if that helps!
Saul
Hi Joseph,
You can do this one of 2 ways.
You can manually set the filter to the parent ID of the repeatable field groups that you want to display or you can provide the ID in the URL so that when you click to the view from lets say the parent, The post ID of the parent will be passed into the URL.
However this should just be a case of manipulating the view filters to get the correct data.
Please share the mockup so that I can understand.
Thanks,
Shane
Shane,
I don't quite understand the two options you explained. I'm also not sure the options answer my original question of creating a separate template associated with a repeatable field group in the same way that templates can be assigned to a custom post type single post and custom post type archive.
Attached are two mockups. "artist-custom-post.png" is the Artist custom post type. It displays a view of related artworks. Each artwork, however, can have multiple images associated with it (to show the work as photographed in an installation from multiple perspectives, for example). The multiple images are components of the repeatable field group (named "Artwork Detail Group," which consists of image, title, year, medium, dimensions, etc.). "repeatable field group.png" displays the first image in the repeatable field group followed by a form followed by the second image in the repeatable field group. (If there were a third image, it would be beneath the second image, and so on.)
Does that explain things more clearly?
Saul
Hi Saul.
"I'm also not sure the options answer my original question of creating a separate template associated with a repeatable field group in the same way that templates can be assigned to a custom post type single post and custom post type archive."
You can if you create a view that is listing out the repeatable field groups. Then you can create a content template and Assign it to your post then add the view to that content template. This will allow the Repeatable field groups to be displayed on the page that has the template assigned.
Ok so where do you want the repeatable field to be displayed. Is it after the user clicks on one of the Artist on the archive? It will then load their page where the repeatable field groups are displayed?
Please let me know.
Thanks,
Shane
Shane,
> ...you can create a content template and Assign it to your post then add the view to that content template.
If I understand what you're saying, a Content Template can be assigned to a single post type. But I don't want to do that. I want to assign some kind of visual layout (whether it's a Content Template or something else) to a repeatable field group.
By the way, does assigning a Content Template to a post type over-ride the assignment of a Layout to that post type?
> Ok so where do you want the repeatable field to be displayed. Is it after the user clicks on one of the Artist on the archive? It will then load their page where the repeatable field groups are displayed?
When someone clicks on an artwork, it should take the visitor to a page with the list of repeatable field groups (artwork imagery in this case).
I hope this clarifies the issue.
Saul
Hi Joseph,
Let me see if I can clarify for you.
"When someone clicks on an artwork, it should take the visitor to a page with the list of repeatable field groups (artwork imagery in this case)."
This is exactly what i'm referring to in the previous post. In order for the Page to display the Repeatable field group, you need to create a view to display that repeatable field group.
If you provide access tot he site then I can setup and example for you and from there you can customize how you want your repeatable field group to be displayed.
Thanks,
Shane
Shane,
Creating an example would be really helpful. Here are credentials to a test site in which you can do anything you like:
wp url: hidden link
user: admin
pass: admin
The post "third test artwork" (hidden link) has two items in the repeatable field group that make it a good sample post.
Saul
Hi Joseph,
So I've created a page here hidden link
This page can be clicked to and it has a view on it that lists out the artwork repeatable fields, however i've added a filter to the view to filter by a URL Parameter "art_id" .
In the link you see that i've provided the url parameter which will then filter for the artwork of the posts with id 811.
How you would make this dynamic is like this.
<a href="<em><u>hidden link</u></em>;">View Artworks</a>
This will dynamically add the artwork ID to the url so when you click to the page it will filter for the correct RFG.
Please let me know if this example is exactly what you require.
Thanks,
Shane
Shane,
Thanks so much for providing the sample page. I think it's exactly what I was seeking. (In retrospect, I probably ought to have used the template to display a single Artwork post.)
Just one question about how you went about creating the page: is it the case that you simply created a View on the backend ("List artwork" / ID 862)? Is there anything more to it than that? Where is the URL slug "list-artwork" derived from?
Thank you!
Saul
Hi Joseph,
Awesome Im happy i was able to help.
"Just one question about how you went about creating the page: is it the case that you simply created a View on the backend ("List artwork" / ID 862)? Is there anything more to it than that? Where is the URL slug "list-artwork" derived from?"
Yes there is one more thing that was done. I added a query filter to the view for the post relationship. This will allow me to pass the ID of the parent that the RFG belongs to into the URL so that the view filters by that parent ID. See Screenshot for the filter.
Please let me know if further clarity is needed for this.
Thanks,
Shane
Shane,
I did see the query filter in the definition of the view. One last question: where did the URL slug ("/list-artwork/") come from?
Saul