Skip Navigation

[Resolved] conditional for empty term meta wysiwyg

This thread is resolved. Here is a description of the problem and solution.

Problem: I'm trying to create a conditional that tests whether or not a Term WYSIWYG field has content.

Solution: There is a known issue with special characters in conditional content, which can break conditionals. As a workaround, convert double-quotes to

& quot;

without the space, and convert single-quotes to

'

Our developers are working on a permanent solution to the problem.

Relevant Documentation:
https://wp-types.com/errata/conditionals-including-special-characters-might-fail/

This support ticket is created 5 years, 2 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.

Our next available supporter will start replying to tickets in about 2.96 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 15 replies, has 3 voices.

Last updated by Ido Angel 4 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1328883

hey,
i have a taxonomy with a wysiwyg as a term meta field.
I am trying to conditionally display a button, only if the field isn't empty:

  [wpv-conditional if="( '[types termmeta='full-gate-text'][/types]' eq '' )"]
      <div class="gate-more open-more">READ MORE</div>
  [/wpv-conditional]

But it doesn't seem to work. My guess is wysiwyg need a slightly different approach because of html.
How do I go about this?

Thx!

Ido

#1328911

Hi, try adding the output="raw" attribute and alternating quotes like this:

[wpv-conditional if="( '[types termmeta="full-gate-text" output="raw"][/types]' eq '' )"]
    <div class="gate-more open-more">READ MORE</div>
[/wpv-conditional]

If that's still not working as expected, add the debug='true' attribute to the conditional and let me know the output.

#1328945

still doesn't work...
needs to be:

[wpv-conditional if="( '[types termmeta="full-gate-text" output="raw"][/types]' ne '' )"]

(ne and not eq, because I want to show the button if it's NOT empty. anyway - I tried both)

Debug also isn't showing when I tried:

[wpv-conditional if="( '[types termmeta='full-gate-text' output='raw'][/types]' ne '' )" debug='true']

thx!

#1328949

The second syntax won't work because of the nested single quotation marks. The first syntax should work in a View of terms. Can you provide login credentials and tell me where to find this on the front-end?

This is exactly what I have, for reference:

Conditional: [wpv-conditional if="('[types termmeta="book-tax-wysiwyg-1" output="raw"]' ne '')"]it is not empty[/wpv-conditional]
Conditional 2: [wpv-conditional if="('[types termmeta="book-tax-wysiwyg-1" output="raw"]' eq '')"]it is empty[/wpv-conditional]
#1329003

Hmm, the login is not working for me. Can you check again?

#1329681

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ido,

Christian is currently on holidays today but will return tomorrow to continue with this.

However i've tested the credentials for him and they do seem to work. The next thing I would like for you to provide is the URL where he can quickly see where you have setup this conditional.

This is to ensure that he has all the information that he would need to debug this for you when he gets in.

Thanks,
Shane

#1329831

hey,
cool - thx.

here are 2 archives - the first should have the button, the 2nd not. but both don't have it:

hidden link

hidden link

the view is "New Gates"

#1330955

Okay I see, the solution I had in place only works in simple cases, and certain combinations of quotation marks break the conditional. I'll have to continue working on this tomorrow, I just wanted to give you a quick update.

#1330961

Appreciated!

#1331527

It turns out there is a known issue with special characters in conditionals: https://wp-types.com/errata/conditionals-including-special-characters-might-fail/
I believe that's why the conditionals here are failing inconsistently between us. In your case, I temporarily deleted most of the content in your WYSIWYG field to remove all quotation marks, and you can see the output here is more like I would expect. I replaced the content for now. It seems that the core issue is the same as the erratum post above, so I have connected this ticket with our internal ticket to resolve that issue. I will keep you posted here as I receive more information. In the meantime, the only workaround I am aware of is to remove special characters from these WYSIWYG fields, or replace " with " in the text content.

#1331531
Screen Shot 2019-09-04 at 9.00.14 AM.png
Screen Shot 2019-09-04 at 9.00.06 AM.png

Screenshots attached.

#1331581

thx Christian!

I tried to replace all " with " in one of the gates - but it still doesn't work. Doesn't this have something to do with the "s and 's in the conditional?

[wpv-conditional if='("[types termmeta='full-gate-text' output='raw'][/types]" ne "")']

cheers!
Ido

#1331653

It looks like the forum is translating the special characters here. I didn't realize there is a single quote in this Gate:
hidden link

I replaced this character:

"

...with this text...

& quot;

(without the space)

...and I replaced this character:

'

...with this text...

&apos;

Here's the format for the conditional:

[wpv-conditional if="('[types termmeta='full-gate-text' output='raw'][/types]' ne '')"]
#1331705

Perfect! Had to do that for this (hidden link) one two - works great!
thank you for all the help!
Ido

#1777601

Quick note: Blocks 1.3 / Views 3.3 have been released, and the updated plugins include improvements to the conditional parser system, including a fix for checking for empty tem fields and term fields with special characters.