Sauter la navigation

[Résolu] I need to have an alternative solution to build a Directory Site

This support ticket is created Il y a 5 années et 7 mois. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Ce sujet contient 10 réponses, a 2 voix.

Dernière mise à jour par Nigel Il y a 5 années et 7 mois.

Assisté par: Nigel.

Auteur
Publications
#1269783

Tell us what you are trying to do?
I'm creating a Directory Site, starting using the Real Estate Reference site, where all companies can create their own page.
To do that I have divided the business typologies by 5 macro area with 1 CPT per macro area.
The typologies are Categories of a Taxonomy.
So, now I need to create the Form to allow the Companies to create their page from the front end. But the Form cannot be the same for all typologies (categories) (the form for an hotel cannot be the same as the form for a turistic village), and then I have tried to use the conditional logic to display the fields related the categories as value. But Form, now, not allow to create conditional logic using the categories as value...
So, I think that the best way to follow, using the resources that Toolset give us for now, is to create a CPT for every single business type instead to have a category in a taxonomy.
But, for every Macro Area I have over than 30 business type, and then in total I will have over 150 CPTs...

So, can you give me a solution to build the Directory Site in a correct way?
There is a way to create CPTs under CPT like as categories in taxonomy, to have all organized by Macro Area?

Is there any documentation that you are following? No

Is there a similar example that we can see? lien caché

What is the link to your site? lien caché

#1270381

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I'm not quite following your description.

Users will submit business listings.

You have created 5 "macro area" CPTs. The listings will be organised into these macro areas, and will so you will set up post relationships between the listings and these macro area CPTs?

Then each of these macro areas is further categorised by some custom taxonomy.

Is that all correct?

So you need a form which conditionally displays fields to submit based upon the selections for the macro area and the sub-categories?

"But Form, now, not allow to create conditional logic using the categories as value"

I don't understand this part. You can conditionally display sections in forms depending on custom fields or taxonomies (https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/#adding-conditional-group).

If the form content varies significantly between macro areas, for example, then it may be worthwhile creating a few separate forms, one for each macro area, and when the user initiates submitting a listing have them first choose which kind of listing, that will open up different forms. Then within the forms conditionally display fields depending on their selections.

#1270807

I'm not quite following your description.

Users will submit business listings.

You have created 5 "macro area" CPTs. The listings will be organised into these macro areas, and will so you will set up post relationships between the listings and these macro area CPTs?

Then each of these macro areas is further categorised by some custom taxonomy.

Is that all correct?
Yes, it is correct, but I will not set up post relationships between the listings and these macro area CPTs.
Only the business listings are categorised by some custom taxonomy into these macro areas.
For example: one of the macro areas is "where I can sleep", and now in the custom taxonomy the Users can select the business type (Hotel, B&B, Touristic Village, ecc...).

So you need a form which conditionally displays fields to submit based upon the selections for the macro area and the sub-categories?
Yes.
If the Users select the "where I can sleep" macro area, and after select "B&B" category, instead of "Hotel" or "Touristic Village", they need to conditionally displays fields by their selection.

"But Form, now, not allow to create conditional logic using the categories as value"
Now, In form I cannot set the conditional logic to display specific fields when a specific category is selected.
And No, with the last form version is not possible to conditionally display sections in forms depending on category in custom taxonomies.
And then I need to have a solution to conditionally display sections in forms instead to use conditional logic for category in custom taxonomies.

If the form content varies significantly between macro areas, for example, then it may be worthwhile creating a few separate forms, one for each macro area, and when the user initiates submitting a listing have them first choose which kind of listing, that will open up different forms. Then within the forms conditionally display fields depending on their selections.
This is what I'm doing.

#1271771

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I'm discussing this with a colleague. Using taxonomies in conditional group conditions is supported. He has it working, but I do not/cannot.

He's finished for the day so I'll resume the discussion with him in the morning.

Thanks for your patience.

#1272463

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Screenshot 2019-06-19 at 10.23.57.png

OK, I have it working.

So with taxonomies you need to insert the conditions manually, you cannot do it directly from the GUI.

Here is an example of me creating a conditional display group where I manually add a condition for the "status" taxonomy to have the term "Accepted" checked:

($(status) eq 'Accepted')

See the screenshot.

Note that when displaying the taxonomies as checkboxes you must use the term name in the test.

Unhelpfully, if you display your taxonomy as a select dropdown rather than checkboxes, you must use the term id in the test rather than the name.

(We have an internal ticket to unify this.)

#1272619

Thanks for the reply.

I have another question:
Can I write a condition inside another condition?

For exemple, I have a cred field to display the terms of the taxonomy,like this:

<div class="form-group strutture-ricettive">
		<label><h2>[wpml-string context='cred-form-' name='Strutture Ricettive']Strutture Ricettive[/wpml-string]</h2></label>
		
      [cred_field field='struttura-ricettiva' force_type='taxonomy' output='bootstrap' display='checkbox']
	</div>

Also, in the same form, I have this conditional logic to display all common fields when a term is selected:

[cred_show_group if="($(struttura-ricettiva) ne '')" mode="fade-slide"]
common fields
[/cred_show_group]

And this work fine.

Inside this conditional logic, I have inserted others conditional logics to display fields related some specific terms selected:

[cred_show_group if="($(struttura-ricettiva) eq 'affittacamere')" mode="fade-slide"]
	<div class="form-group space">
		<label><h2>[wpml-string context='cred-form-' name='Descrizione Struttura']Descrizione Struttura[/wpml-string]</h2></label>
		[cred_field field='post_content' output='bootstrap']
	</div>
[/cred_show_group]

but when I select the "affittacamere" term, the conditional logic don't display the field inside on it... Why?

You can try to open this link to test what happen: lien caché

Also, it is possibile to write multiple terms inside conditional logic like that?

[cred_show_group if="($(struttura-ricettiva) eq 'affittacamere, hotel, ecc..')" mode="fade-slide"]
[/cred_show_group]
#1272821

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Regarding nested conditions, it should work.

I just tested it with the following:

	<div class="form-group">
		<label>Statuses</label>
		[cred_field field='status' force_type='taxonomy' output='bootstrap' display='checkbox']
	</div>
	[cred_show_group if="( $(status) ne '' )" mode="fade-slide"]
		<p>Any status has been chosen</p>
		[cred_show_group if="($(status) eq 'Accepted')" mode="fade-slide"]
			Accepted status has been chosen
		[/cred_show_group]
	[/cred_show_group]

You can see the results in the screen recording, it works exactly as expected: lien caché

Remember from above that when testing for a term you should use the name, not the slug, so I'm guessing ($(struttura-ricettiva) eq 'affittacamere') should probably be ($(struttura-ricettiva) eq 'Affittacamere')

Check that, and I'll look at the question of passing multiple terms and get back to you.

#1272847

So, I'm still using the slug... Using the Term Name, it work fine!!!
Thanks

#1273337

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Regarding passing multiple terms, the answer is no, that's not possible.

The taxonomy field you test (e.g. $(struttura-ricettiva) ) is an array of terms and the only test you can make is whether the value you pass as a string (e.g. "affittacamere") is contained in that array or not. Passing more than one term, you are essentially just passing a longer string to search for (which then won't be found at all).

But you can add multiple conditions connected with AND or OR (https://toolset.com/documentation/user-guides/cred-conditional-display-engine/#logic-operators), and so you can test each of the multiple terms individually, connected with OR.

#1274901

Thanks for the reply.
I will try it!

#1275555

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

OK, let me know how you get on.