Skip Navigation

[Resolved] Creating conditional category hierarchy on post form

This support ticket is created 2 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Author
Posts
#2106945

Hi,

I am creating a listing directory for e-bikes and e-motorcycles. The client wants to have users input fairly detailed information when they submit a listing about the make & model of the bikes or motorcycles or scooters. In principle, I understand how to do this, but I'm stuck on creating this inside the Post Form and how to set-up the category hierarchy properly to make things work together.

There are 4 tiers:
Category --> Type --> Make --> Model

So, as an example, a user could have an eBike (Category) --> Mountain (Type) --> Cannondale (Make) --> Habit Neo (Model). There are 4 different categories (eBikes, eMotorcycles, eScooters, Parts) and each have a few Types, and each Type has many many makes and models.

Obviously, I could just create a massive checkbox list but that doesn't feel like good user experience design. Instead, I am trying to create a series of conditionally shown dropdowns on the user form that show the proper Type, Make, and Model depending on the Category, Type, or Make chosen. Sequentially, the user would first select the Category, then the Type, then the Make and Model.

It's possible I can convince them to get rid of "Types" to simplify the selection a little bit.

I'm trying to understand how to set this up properly using Toolset Taxonomies and the Post Form to add a listing.

How should I go about creating the taxonomies? Should the category, type, make, and models all be different taxonomies that are only "shown" conditionally on the Post Form? Or, should there be parent-children relationships? If there is a parent-child relationship on the taxonomy, how do I get the dropdowns to show only the parent fields first and then pop-up the child fields?

Any help would be greatly appreciated! Thank you!

#2107279

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

If you need a selection field for each level ( i.e. Category, Type, Make & Model ), then yes you'll need to add 4 custom taxonomies, one for each of them. The challenge will be that it is not possible to create a relationship between the taxonomy terms. This means that by default, all terms will be shown in the dropdown for all the taxonomies, every time.

Through conditional output in forms, you can show/hide the taxonomy fields as a whole based on the selection from another taxonomy field, but you'll not be able to limit the dropdown to only show/hide related terms.

In this approach, you'll need to include an extensive custom script code to detect changes in the selection of the 4 taxonomy fields and then show or hide only the manually entered selected/related terms based on the already selected terms.

Another alternative can be to replace 4 custom taxonomies with 4 custom post types Categories, Types, Makes & Models. These post types can be linked together through one-to-many post-relationships:

1. One Category can have many Types
2. One Type can have many Makes
3. One Make can have many Models
4. One Model can have many Listings

In this approach, when the user will be submitting a Listing through the front-end form, he/she will only need to select the related "Model" post and as a result, indirect relationships will naturally be formed with the upper-level post types too.

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

regards,
Waqar

#2107709

Thanks! This is incredible detailed. The custom post types is actually a really interesting way to tackle this.

Just to expand this idea, how would filter work with this? I've perused the support ticket archive but couldn't find anything specific, so apologize if I'm restating something that already exists. Since each of these are "custom post types" and not just taxonomy, we'd like the front-end user to be able to filter by "Type" and "Make" so they can search by "Mountain eBikes" or "Cannondale." The relationships aspect makes that easier, but the main View should be filterable. Is that still possible by using custom post types instead of taxonomy? Thanks.

#2108305

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back and glad my message helped.

Yes, in this approach of using custom post types joined through relationships, you'll have the ability to search by different level items in the views.

Just as you add the search field for the taxonomies or custom fields, you'll be able to add a relationship search filter, where you can specify which levels of these relationships should be included.

On the front-end search form, visitors will see the separate fields to select Category, Type, Make, and Model. When any category will be selected, only the related options will become available in the type field. When any type will be selected, only the related make options will become available. And the same will happen for the model field when a make will be selected.

#2109331

Makes a ton of sense. Thank you!

#2110381

Actually, one more question:

I realized I didn't ask this. I have set up a post relationship custom search. Works great. However, with the recommended set-up, you must first select Categories, then select Type, then select Make, then select Model. I believe this is what was written above.

Is there anyway to have four separate post relationship custom searches, where the user can individually select a Make without selecting a Category and Type first (for example)? I could just set-up four separate post relationship custom searches, but is there a way to disable the appearance of children in the filter? Happy to enable some custom scripting here too.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.