Skip Navigation

[Resolved] CTP relationships in dropdowns

This support ticket is created 7 years, 3 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
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 16 replies, has 2 voices.

Last updated by Bochnacki 7 years, 3 months ago.

Assisted by: Noman.

Author
Posts
#559854
relationship-error.jpg

I have created a CTP relationship - Make -> Model ->Version.
In the parametric search I have three dropboxes: first for the Make, second for the Models, third for the Version.
If in the first dropbox I choose Audi, then in the second dropbox will appear only Audi models. If I choose Audi A4, then the third dropbox will have only A4 versions. It works well.

The problem is that if any Make has no Model and Version, it shows nothing and does not search anything. Screen "relationship-error.jpg".
Is this the way it works? If so, how can this change?
There are many car brands that do not have models and many models that have no version.

#559867

Noman
Supporter

Languages: English (English )

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

Hi Bochnacki,

Thank you for contacting Toolset support.

1. Please confirm that Make, Model and Version are Custom Post Types or Custom fields? It these are CPTs then how you have displayed these in dropdown? Because we can not display CPTs in dropdown Filter using built-in options of Toolset.

2. Please provide back-end screenshots of the View and more related screenshots of CPT or fields or relationships.

Thank you

#559895
make.jpg

"1. Please confirm that Make, Model and Version are Custom Post Types or Custom fields?"
- It's CTP.

"It these are CPTs then how you have displayed these in dropdown? Because we can not display CPTs in dropdown Filter using built-in options of Toolset." -
I do not understand what you are writing because it is the Toolset mechanism:

[wpv-control-post-relationship ancestors="osobowe-marka>osobowe-model>osobowe-wersja" format="%%NAME%% <span>(%%COUNT%%)</span>" url_param="wpv-relationship-filter"]
	[wpv-control-post-ancestor type="select" default_label="Marka" format="%%NAME%% <span>(%%COUNT%%)</span>" ancestor_type="osobowe-marka"]
	[wpv-control-post-ancestor type="select" default_label="Model" format="%%NAME%% <span>(%%COUNT%%)</span>" ancestor_type="osobowe-model"]
	[wpv-control-post-ancestor type="select" default_label="Wersja" format="%%NAME%% <span>(%%COUNT%%)</span>" ancestor_type="osobowe-wersja"]
[/wpv-control-post-relationship]

I attach the screen of the CPT "Makes".

#559905

Noman
Supporter

Languages: English (English )

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

Okay, I can see you are using post relationship filter.

To further debug this issue I need to take a look relationship between CPTs in your setup.
Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please add the Link to the [View, Page] Edit Screen.

Thank you

#559918

Noman
Supporter

Languages: English (English )

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

Please provide View link, and the page link where you have inserted this view.

#560103

Noman
Supporter

Languages: English (English )

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

I have been working on it, trying to understand your setup. I have created a new Test View:
hidden link

Below are my findings:
- If we add one-to-one relational filter >> it shows correct Count and results as well.
- If we add one-to-many filter >> set all relations for parent >> it shows correct results.
- If we add one-to-many filter >> set only ONE relation for parent >> it shows wrong results >> because View expects all values to be selected based on how this post relational shortcode works.

I have found that this is expected behavior so far for this filter or shortcode. So this would need to be done using Custom coding and using wpv_filter_query (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query) as per support policy (https://toolset.com/toolset-support-policy/). We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/

Alternate way that can help is:
- If you create a Default post:
==> default model post
==> default version post
- And assign any post that does not have any make / model, to these default posts.
- Then default make/model will be passed in filters upon searching.
- This way all un-assigned posts will still show up (because behind they have default model, version selected still).

Thanks

#560133

"- If you create a Default post:
==> default model post
==> default version post"
- I do not understand. How do I do this? Are you talking about CTP?
If so, how do search engines work? (... ancestors="osobowe-marka>osobowe-model>osobowe-wersja" ...)

"- And assign any post that does not have any make / model, to these default posts." - How?
Please explain.

#560513

Noman
Supporter

Languages: English (English )

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

Ok I have think more on this and after playing around a bit I am giving an example for the above alternate method. Considering below hierarchy:

Car 1 - this is post created with CRED form.
  >> make toyota
     >> toyota model (default)
     >> toyota version (default)

If user creates a post named “Car 1” >> and select only Make (toyota) for it >> you need to create a php code / script using cred_save_data >> that will automatically create Model (toyota model) and Version (toyota version) for the same post, whereas name can be taken from the Make like in above example.

https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This way each newly created Post will have some Default model and make, which will allow the search form to work fine as well, since the relation is completed this way.

Both methods require coding so its upto you which way you would like to go. Thanks

#560562

Ok, thanks. But I do not quite understand what the cred_save_data code would do.

#560721

Noman
Supporter

Languages: English (English )

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

It will be required to automatically create related default post for Model and Version. 2 posts like this for each new entry as in the above example:
>> toyota model (default)
>> toyota version (default)

Thanks

#560730

For the third time you write me the same thing and I ask for the third time - what do you mean by writing:
>> toyota model (default)
>> toyota version (default)

You see, I can not understand what is being said. Maybe I'm stupid, maybe I do not know English well, I do not know.
Please, can you join some moderator, who will be able to explain it to me?

#560922

Noman
Supporter

Languages: English (English )

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

toyota model 1.png
toyota version 1.png

Let me try to explain it again and make it more clear with screenshots:
>> toyota model:
This is a new post that needs to be automatically created in Osobowe modele CPT, for the newly added entry (Car 1, Car 2, Car 3, etc...). See attached screenshot toyota model 1.png

>> toyota version:
This is a new post that needs to be automatically created in Osobowe wersje CPT, for the newly added entry (Car 1, Car 2, Car 3, etc...). See attached screenshot toyota version 1.png

We are doing this so that every new car entry will have some model and some version assigned to it, here we are kind of adding dummy model & version (kind of fake data).

Let me re-phrase your original question as well:

Question: Can the multiple parent/child search filters work, if there is ONLY ‘make’ selected for an entry (Car 1) and there is no ‘model’ and ‘version’ is selected for that Car 1, can it work?

Answer: No, it's not possible to have child post empty. For the current search filters to work, all child posts should have some posts or values and only then the filters will work. If you would like me to submit this as a feature request, please let me know and I will submit this to our team for further consideration.

Thanks

#560997
post-view.jpg

Thanks for the explanation.

I added the "Toyota" Make. I have assigned to this Make "toyota model 1" and "toyota version 1".
1. Did I do well?
2. This must be repeated for every Make? There are over 150 ...

I added the post "Toyota" but did not choose either Model or Version. The dropdown shows "Toyota (0)", the search does not find this post.
On the other hand, in the post view, a problem is shown on the screen "post-view.jpg".

#561277

Noman
Supporter

Languages: English (English )

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

1. Did I do well?
==> Yes you have done it right.

2. This must be repeated for every Make? There are over 150 ...
==> Yes, that’s true.

3. I added the post "Toyota" but did not choose either Model or Version. The dropdown shows "Toyota (0)", the search does not find this post.
==> Yes this is expected and happening because of the same issue that I talked in my previous answer, because there are no child posts assigned and search results and form filters does not show or count it as a valid result. Let me know if you would like to submit both these as feature request, this actually happens because of one same limitation.

On the other hand, in the post view, a problem is shown on the screen "post-view.jpg".
==> This is related to breadcrumbs being repeated, its basically a separate issue. Please kindly open a new ticket for this second problem if you need help with this. This will help other users with similar problems to find solutions when searching the forum, I am not allowed to handle multiple issues in the same ticket as per support policy. https://toolset.com/toolset-support-policy/

Thanks

#561283

Thanks.
"Let me know if you would like to submit both these as feature request, this actually happens because of one same limitation." - Yes i would.