Skip Navigation

[Resuelto] Conditional Output in Visual Editor Cell

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Conditional Output in Visual Editor Cell - check multiple fields with and as well as or clause using the conditional statement with custom shortcode

Solution:
You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/conditional-output-in-visual-editor-cell/#post-1208590

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created hace 5 años, 9 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Este tema contiene 16 respuestas, tiene 2 mensajes.

Última actualización por geoffD hace 5 años, 9 meses.

Asistido por: Minesh.

Autor
Mensajes
#1207967

Hello

I have a CPT 'User Will' wth fields 'about-yourself-status', 'financial-assets-status', 'residuary-estate-status', 'executors-status' and 'guardians-status'

I also have a custom shortcode [child_func] which if ==1 tells me that the user has children.

What I want to achieve is to display the text 'VIEW NOW' but only if the fields above ( 'about-yourself-status', 'financial-assets-status', 'residuary-estate-status', 'executors-status' and 'guardians-status') all equal 'Yes' however I only want 'guardians-status' to equal 'Yes' if the shortcode [child_func] ==1

This happens on the template page for the CPT 'User Will' so al the fields are present on the page...

I can manage the conditional part for the first 5 fields but not for the 'guardians-status'

[wpv-conditional if="( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )"] VIEW NOW [/wpv-conditional]

Hope that makes sense..
Many thanks

Geoff

#1208080

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - as I understand you want two conditions?

First case:
( 'about-yourself-status', 'financial-assets-status', 'residuary-estate-status', 'executors-status' and 'guardians-status') all equal 'Yes'

Second case:
guardians-status equal 'Yes' and shortcode [child_func] ==1

If yes, what how you want to connect the first case with the second case
- First case AND Second case
- First case OR Second case

Can you please share the above information.

#1208120

Hi Minesh

Thank you for your speedy response... and yes you're correct with the two cases...and they both need to happen at the same time i.e. First case AND Second case

Many thanks

Geoff

#1208195

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

What if you try to use the following code:

.
[wpv-conditional if="( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' ) AND (  [child_func] eq '1' )"] 

VIEW NOW 

[/wpv-conditional]

Where:
- Please do not forget to register the shortcode child_func at:
=> Toolset => Settings => Front-end content => Third-party shortcode arguments

#1208271

Hi Minesh

I only want to include AND ( $(wpcf-guardians-status eq 'Yes' ) in the argument if [child_func] eq '1' )"] so as I've tried to demonstrate below..but I don't think this will work

[wpv-conditional if="( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )

AND IF( [child_func] eq '1' )"] AND ( $(wpcf-guardians-status eq 'Yes' )

So to simplify:
IF
'about-yourself-status'
'financial-assets-status'
'residuary-estate-status'
'executors-status'
ALL = 'Yes'

AND ONLY IF [child_func] = 1
AND
'guardians-status'
= 'Yes'

RETURN TRUE

So Example #1 for returning true:

'about-yourself-status' = 'Yes'
'financial-assets-status' = 'Yes'
'residuary-estate-status' = 'Yes'
'executors-status' = 'Yes'
'guardians-status' = 'Yes'
[child_func] = 1
TRUE

Example #2 for returning True:
'about-yourself-status' = 'Yes'
'financial-assets-status' = 'Yes'
'residuary-estate-status' = 'Yes'
'executors-status' = 'Yes'
'guardians-status' = 'Yes'
[child_func] = 0
TRUE

#1208307

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Can I see where you try to apply this condition?

Could you please share problem URL and access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1208544

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Could you please check now. I've added the following conditional statement:

[wpv-conditional if="(( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND ((  [child_func] eq '1' ) AND ( $(wpcf-guardians-status) eq 'Yes' ))"]
 <p>VIEW NOW </p>
[/wpv-conditional]
#1208564

Hi Minesh

Thanks for looking into this..

This only works if the person has the guardians section active and complete (5) however if the user doesn't have children then this section doesn't show for them and [child_func] = 0

So I need it to be something like:

IF
[wpv-conditional if="(( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND [child_func] not equal 1

OR

[wpv-conditional if="(( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND [child_func] equal to 1 AND ( $(wpcf-guardians-status) eq 'Yes' )

Best regards Minesh

#1208570

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - do you mean that you want to apply OR clause?

Or you want to have two different conditional statements?

#1208576

Hi Minesh

Yes, I think it would have to be 2 different statements with an OR function..so

IF Condition 1 OR Condition 2 is met then return TRUE

Many thanks

Geoff

#1208585

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

I do not understand this - because when you use OR - it will give you TRUE in both cases - do you want that? If yes:

Please use the following conditional statemenets:

[wpv-conditional if="(( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND ((  [child_func] ne '1' ) )"]
 <p>VIEW NOW </p>
[/wpv-conditional]
[wpv-conditional if="(( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND ((  [child_func] eq '1' ) AND ( $(wpcf-guardians-status) eq 'Yes' ))"]
 <p>VIEW NOW </p>
[/wpv-conditional]
#1208587

Yes but how do I include both true conditions using an OR?

So to simplify I need

if 1 + 1 = 2

OR

if 2+2 =4

THEN

PERFORM TASK

#1208590

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Can you please check this:

[wpv-conditional if="((( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND ((  [child_func] ne '1' ) ))  OR  ((( $(wpcf-about-yourself-status) eq 'Yes' ) AND ( $(wpcf-financial-assets-status) eq 'Yes' ) AND ( $(wpcf-residuary-estate-status) eq 'Yes' ) AND ( $(wpcf-executors-status) eq 'Yes' )) AND ((  [child_func] eq '1' ) AND ( $(wpcf-guardians-status) eq 'Yes' )))"]
 <p>VIEW NOW </p>
[/wpv-conditional]
#1208609

Hi Minesh

That worked a treat!...Thank you..

I have a couple of other small issues that you may be able to help with quickly:

1. When I use a date field with a pop up date select calendar, it takes a few seconds to show the date when it's been selected..why is there this delay? An example page is here:
enlace oculto

2. After setting up my site, every url seems to have the prefix index.php/ for some reason...e.g enlace oculto name.com/index.php/the-page-i-need rather than enlace oculto name.com/the-page-i-need Why is this?

Best regards

Geoff

#1208618

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Glad to know that solution I shared works for you. I'm ending my shift here and have a good weekend.

May I kindly ask you to open a new ticket or your every new question. This will help other users searching on the forum as well as to write correctly resolution summary for which this ticket was open.

Thank you for understanding.