Skip Navigation

[Resolved] Conditional HTML not working

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

Problem:
Conditional HTML I use on my site is producing unexpected output.
What can I do?

Solution:
First, confirm that the issue is really due to the HTML conditional.
Often, the content that should display is marlformatted, for example.
Try to output what you expect to see without any condition.

If that works, but it fails if put in a condition, then output something simple withing your HTML condition instead of what you expect. A simple "HERE I AM" string for example.

Does that show when you expect? If not, the HTML condition itself fails, due to maybe checking upon wrong content or being malformed on its own.

You can check the relevant DOC to fix that, or ask help from our support.

Relevant Documentation:

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

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

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by mikeF-8 5 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1334057

I am trying to display social network icons as png in a content template based on if there is any entry into a field in a form. If the user doesn't enter a url for their social page, I don't want to display the image.

I have tried:

[wpv-conditional if="( $(facebook-page-link) ne '' )"]hidden link" alt="" width="64" height="64">[/wpv-conditional]

You can see the results I'm getting at hidden link

#1334109

I see you get raw Output of the content wrapped in the Condition.

This should be because of the invalid HTML syntax, please see the inline comments to the code below

[wpv-conditional if="( $(facebook-page-link) ne '' )"]<!-- If facebook-page-link is not empty-->
  <!--Below HREF has no "", which any HREF Must have, like href="<em><u>hidden link</u></em>". Hence, it should read href="[types field='facebook-page-link']"-->
  <!--Additionally, [types field='facebook-page-link'] will not give a clean URL, you should pass the output="raw" attribute, to get only the URL without HTML-->
  <!--Finally I think you wanted to use "img src", not "src":<em><u>hidden link</u></em>, is this correct? Thhen you'd have to write <img src="<em><u>hidden link</u></em>"> -->
  <a href=[types field='facebook-page-link']><src="<em><u>hidden link</u></em>" alt="" width="64" height="64"></a>[/wpv-conditional]

Concluding, I think the issue is within the HTML only.
I'd simply input the HTML into the page first without any HTML Condition.
If it works, it will also work within the condition.

Please let me know if I can further help.
I'll be limited on HTML and CSS assistance, I can help only partially with styling and HTML structuring, but please don't hesitate to ask if anything is unclear, I will see to point in the right directions.

#1336153

My issue is resolved now. Thank you!