Skip Navigation

[Resolved] Problem with nested conditionals

This support ticket is created 6 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.

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Carlos Rojas 6 years, 9 months ago.

Assisted by: Carlos Rojas.

Author
Posts
#535587
screenshot-hundeurlaub.dev 2017-06-12 12-26-34.png
screenshot-hundeurlaub.dev 2017-06-12 12-23-37.png

I've noticed that some of my conditionals seemed to have stopped working. I'm running Views 2.3.1 - I have tested and upgraded to 2.4 (with wp 4.8) and the problem remains. I suspect the problem started in 2.3

Sample 1 - the original code

[wpv-conditional if="($(wpcf-acc-garden-free-run) eq '1' AND $(wpcf-acc-garden-public) eq '1')"]
    <li>
        <i class="fa fa-paw"></i>
        <span>Dein Hund darf sich am Grundstück bzw. auf dem Teil des Grundstücks frei bewegen</span>
    </li>

    [wpv-conditional if="($(wpcf-acc-garden-fenced-area) eq '1')"]
        <li>
            <i class="fa fa-paw"></i>
            <span>Das Grundstück ist eingezäunt und darf vom Hund benutzt werden
                <span class="badge hu-badge-red">[types field="acc-garden-fence-height"][/types] cm  </span>

                [wpv-conditional if="(NOT(empty($(wpcf-acc-garden-fenced-size))))"]

                    <span class="badge hu-badge-red">[types field="acc-garden-fenced-size"][/types] [types field="acc-garden-fenced-size-units"][/types]</span>

                [/wpv-conditional]

            </span>
        </li>
    [/wpv-conditional]

[/wpv-conditional]

Removing the outer conditional

<li>
    <i class="fa fa-paw"></i>
    <span>Dein Hund darf sich am Grundstück bzw. auf dem Teil des Grundstücks frei bewegen</span>
</li>

[wpv-conditional if="($(wpcf-acc-garden-fenced-area) eq '1')"]
<li>
    <i class="fa fa-paw"></i>
    <span>Das Grundstück ist eingezäunt und darf vom Hund benutzt werden
                                    <span class="badge hu-badge-red">[types field="acc-garden-fence-height"][/types] cm  </span>

                                    [wpv-conditional if="(NOT(empty($(wpcf-acc-garden-fenced-size))))"]
                                        <span class="badge hu-badge-red">[types field="acc-garden-fenced-size"][/types] [types field="acc-garden-fenced-size-units"][/types]</span>
                                    [/wpv-conditional]
                                </span>
</li>
[/wpv-conditional]

Removing the inner conditional

[wpv-conditional if="($(wpcf-acc-garden-free-run) eq '1' AND $(wpcf-acc-garden-public) eq '1')"]
<li>
    <i class="fa fa-paw"></i>
    <span>Dein Hund darf sich am Grundstück bzw. auf dem Teil des Grundstücks frei bewegen</span>
</li>

[wpv-conditional if="($(wpcf-acc-garden-fenced-area) eq '1')"]
<li>
    <i class="fa fa-paw"></i>
    <span>Das Grundstück ist eingezäunt und darf vom Hund benutzt werden
                                    <span class="badge hu-badge-red">[types field="acc-garden-fence-height"][/types] cm  </span>


                                        <span class="badge hu-badge-red">[types field="acc-garden-fenced-size"][/types] [types field="acc-garden-fenced-size-units"][/types]</span>

                                </span>
</li>
[/wpv-conditional]

[/wpv-conditional]

The original sample above is outputting types shortcodes instead of process them. If I remove the outer or inner of the 3 levels of conditionals, then the output is rendered correctly (although the conditional logic is not correct).

#535592

I've been chatting to the developer who posted this issue - https://toolset.com/forums/topic/shortcodes-are-not-parsed-when-nested-wpv-conditional-are-used/ and the effect appears to be identical.

#535705

Carlos Rojas
Supporter

Hello Simon,
Thank you for contacting WPML support. I'll be happy to help you with this.

I believe your conditionals are missing some parenthesis, please see the difference between this two lines:

[wpv-conditional if="($(wpcf-acc-garden-free-run) eq '1' AND $(wpcf-acc-garden-public) eq '1')"]

and

[wpv-conditional if="( '[wpv-post-excerpt]' ne '' ) AND ( $(wpcf-consultant-gender) eq 'female' )"]

The conditionals are isolated, for example: [wpv-conditional if="( FIRST_CONDITIONAL ) AND ( SECOND_CONDITIONAL )"]

Please let me know if you need any further assistance and I will be happy to help.
Kind regards,
Carlos

#535706
screenshot-hundeurlaub.dev 2017-06-12 20-00-39.png

As I mentioned in my original - these conditionals haven't changed, they've just stopped working after an upgrade.

I've tried several combinations of parenthesis and double/single quotes

Here's another example with the same problem:

                [wpv-conditional if="($(wpcf-acc-training-option-professional-workshops) eq '1' ) OR ($(wpcf-acc-training-option-dog-events) eq '1' ) "]
                    <h3 class="hu-page__subsection-title">Hundeseminare</h3>
                    <ul class="hu-paw-list">
    
                        [wpv-conditional if="($(wpcf-acc-training-option-professional-workshops) eq '1')"]
                            <li>
                                <span>Es werden im Haus Hundeseminare/ Workshops/ Hundekurse angeboten</span>
                            </li>
                            [types field="acc-professional-workshops-notes"][/types]
                        [/wpv-conditional]
    
                        [wpv-conditional if="($(wpcf-acc-training-option-dog-events) eq '1' )"]
                            <li>
                                <span>Unser Standort eignet sich für die Veranstaltung von Seminaren o.ä. (z.B. Hundetraining, Hunde-Workshop). Er ist für Gruppen geeignet.</span>
                            </li>
        
        
                            <span>mögliche Anzahl an Teilnehmer <span class="badge hu-badge-red">[types field="acc-training-events-participants"][/types]</span></span>
        
                            <span>mögliche Anzahl an Hunden <span class="badge hu-badge-red">[types field="acc-training-events-dog-count"][/types]</span></span>
    
    
                            [wpv-conditional if="(NOT(empty($(wpcf-acc-training-events-notes))))"]
                                <li>
                                    [types field="acc-training-events-notes"][/types]
                                </li>
                            [/wpv-conditional]
    
                        [/wpv-conditional]
                    </ul>
                [/wpv-conditional]
#535728

Carlos Rojas
Supporter

I had run some tests locally and it doesn’t seem to be a problem in my end, so there must be something different in your setup and I need to investigate.

Could you please share a link with a copy of your site. Please use the plugin called Duplicator and don't forget to share the installer.php file too.

Regards,
Carlos

#535949

Carlos, my site is a bit of a monster. Could you share you test samples with me and I'll run them in my environment?

#536120

Carlos Rojas
Supporter

Hello Simon,

I would like you to send me a copy of your site (using the Duplicator plugin) because I need to verify that the issue can be replicated and also I want to do some further testing on a safe environment. You can read on how to create a copy of your site using Duplicator in this link: https://toolset.com/faq/provide-supporters-copy-site/

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the site, it is still good practice to backup the site before providing us with a copy.

**IMPORTANT**

Please make a backup of site files and database before providing us with a copy.

Please let me know if you need any further assistance and I will be happy to help.
Kind regards,
Carlos

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