Saltar navegación

[Resuelto] When to use a repeatable field group over a post type relationship

This support ticket is created hace 5 años, 3 meses. 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/Karachi (GMT+05:00)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Waqar hace 5 años, 3 meses.

Asistido por: Waqar.

Autor
Mensajes
#1345731

Tell us what you are trying to do?
I am struggling with determining when to use a repeatable field group and when to create a new custom post type and connect it with a relationship

Is there any documentation that you are following?
I have seen both ways used in the toolset documentation for connecting houses with rooms. I am now wondering, what is the better way to do it and why? Are there speed benefits with one or the other? Or are there feature limitations with one or the other?

Thanks for clarifying. Tobias

#1345929

Hi Tobias,

Thank you for contacting us and I'd be happy to assist.

Your observation is correct and both repeatable field groups and the post-relationships can be used to connect the posts together.

From the performance/speed point-of-view, there should be no benefit of using one over the other, since both are stored in the same dedicated post-relationship structure, at the core.

The difference comes based on the usage requirement. One major edge that post-relationship has over the repeatable field groups is the use in front-end search filters in views.

You'll be able to include a front-end search filter to select the results from all "rooms" posts, which are connected to a particular "house" post (and vice versa) only if they're joined through a post-relationship. The same won't be possible, through the repeatable field group connection.

In general, repeatable field groups are suitable for a connection, where child posts don't hold much significance in the absence of the parent post. Examples:

- House -> Room
- Resume -> Resume sections (e.g. qualification, past experience)
- Post -> Gallery Items

The post-relationships are useful when we need to use a front-end search filter for the connection and both connected entities hold some kind of a standalone significance. Examples:

- Country -> City -> House
- Company -> Job Opening
- Movie -> Actor

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1346657

Thank you Waqar for this great and clear explanation. Just to be sure: if I wanted to create a location database (for example for film production), where I can also search with a Frontend filter for all available kitchen, it would be better to create a post relationship between houses and rooms. - But if I wanted to create something like airbnb where I am looking for a house and then just wanted to see the kitchen too, I could get away with a repeatable group field. - In general: if I am not sure it I wanted to filter in the frontend, it might be better to create a post relationship since it is more flexible, but for galleries and simple stuff like multiple emails, etc repeatable field groups keep things easily together and do not require to add a new post field. - Did I get this right? Thanks a lot, I feel already much clearer in my head 🙂

#1346703

Here‘s one more setup I am struggling with:
- i have a database with contacts
- based on the job of the contact I would like to show different additional field groups, f.ex resumes for actors, voice samples and characteristics for offvoice artists
If I wanted to search for only male actors who studied at a certain university in the fronted I would have to add the resume as a post type, correct?

#1347067

Hi Tobias,

Thanks for writing back and glad my message helped.

All points in your first message are absolutely correct and I couldn't have summarized this better 🙂

As for the second message, before you decide the structure of those items, there are a few key points, that I'd like to mention:

1. If you'd like to filter the results from a particular post type, the desired criteria entity should be directly attached to that post type. It shouldn't be linked to a related post ( i.e. either through the post-relationship or repeatable field group ).

The desired criteria entity for the search query can be:

a). Custom field attached to that post type

b). Taxonomy attached to that post type

c). Custom post type attached to that post ( post-relationship filter )

2. Only one post-relationship filter can be used in a view at a time, which means that it should be used wisely and only for the search filter which is unavoidable.

To make this more clear, if a custom post type "A" is attached to multiple post types e.g. "B" and "C" (through post-relationships), you can only include a single post-relationship filter, in a single view, for either "A -> B" or "A -> C".

3. However, if post types are connected indirectly, i.e. A is connected to B (A -> B) and B is connected to C (B -> C), then it is possible to add a multi-level search filter for A->B->C.
( ref: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/ )

Your visitor will first select a post type C in the first field and then only related posts from B will populate as the options in the second field and then upon choosing the B post, only related A posts will show in view that is set to show A posts )

Based on the above points, if you'd like to search through a post type "Actors", you can include a "Gender" custom field to this post type ( with the options "male" & "female" ) and a custom taxonomy named "University", which will have the university names as the taxonomy terms.

As a result, you'll be able to add search fields in the view, which can filter the results based on "gender" and "university".

You'll be able to connect other post types (like "resumes, voice samples and characteristics for off voice, etc) to this "Actors" post type through post-relationships, but as mentioned in the point #2, you'll be able to use only one of those connections, as a front-end post-relationship filter, in the view.

regards,
Waqar