Saltar navegación

[Resuelto] Conditional block not showing custom field in live view

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

Problem:

The customer faced an issue where a conditional block in Toolset was not displaying the expected information on the live site, even though it appeared to work correctly in the admin view. The block was designed to show information from a custom field if the field was populated and to hide it if the field was empty. This issue occurred specifically on the "profile pages" of therapists under the "Where I offer therapy" section.

Solution:

We suggested enabling debugging on the conditional block to gather more information. The debug data revealed that the condition was incorrectly testing if the custom field's value equaled a specific string, rather than checking if the field had any value. We recommended configuring the condition to test for an empty field instead. After applying this adjustment, the customer confirmed that the issue was resolved.

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Zona horaria del colaborador: America/Sao_Paulo (GMT-03:00)

Etiquetado: 

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Mateus Getulio 1 year, 9 months ago.

Asistido por: Mateus Getulio.

Autor
Mensajes
#2719711
Conditional issue with custom field view live mode.png
Conditional issue with custom field view in edit mode .png

I have a number of conditional blocks that only show information if the condition is true. Most work fine however one I set up seems to work in the admin view but does not work on the live site.

This conditional block should display information from a custom field if the field is populated and doesn't show anything if the field has nothing in it.

The conditional block is on the 'profile pages' of the therapists and is 3/4 of the way down the page under the section 'Where I offer therapy'

You will see that every therapist has an entry for their 'main' clinic but under that same heading there is a grid which has 3 columns and the 2nd and 3rd column allows alternative 'other' clinic locations to show if there is something entered into the 'other clinic custom fields'

I watched the 'How to use conditional block' but can't seem to make it work for this section

Is there a similar example that we can see?
enlace oculto

What is the link to your site?
enlace oculto

#2720062

Mateus Getulio
Colaborador

Idiomas: Inglés (English )

Zona horaria: America/Sao_Paulo (GMT-03:00)

Hello Brian,

Thank you for getting in touch.

Can you enable the debugging on the conditional block that you're checking for the empty field on and let me know what the debug data you're getting from this is.

From there we will know how best to proceed.

Thanks,
Mateus

#2720063

Thanks Mateus

Here is the debug data as seen on the front end

####################
wpv-conditional attributes
####################
Array
(
[if] => ( ( $(wpcf-other-location-1) = 'other-location-1' ) )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( ( $(wpcf-other-location-1) = 'other-location-1' ) )
--------------------
--------------------
Converted expression: ( ( 'Barnsbury Therapy Rooms
144 Liverpool Road
Islington
London
N1 1LA' = 'other-location-1' ) )
--------------------

#2720074

Mateus Getulio
Colaborador

Idiomas: Inglés (English )

Zona horaria: America/Sao_Paulo (GMT-03:00)

conditional.png

Hello Brian,

It looks like the conditional is testing if the value of the field equals 'other-location-1'.

If you were to test if the field has some value, the debug would show something like this:

Array
(
    [if] =>  NOT ( empty( $(wpcf-other-location-1)) ) 
    [debug] => true
)

Can you please try to configure the conditional to look like the screenshot bellow to see if you get different results?

Thank you,
Mateus

#2720695

Amazing, as always you guys just solve stuff, Thanks so much.