Skip Navigation

[Gelöst] Check HTML conditional for true/false booleans

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
I have a Function that returns a boolean (true or false)
I want to use that in a HTML condition, but it does not work.
What am I doing wrong?

Solution:
If you expect the function to return a boolean, the value to check agains should be 1 or ‘1’ for true and 0 or ‘0’ for false.

Example Code:

[wpv-conditional if="( is_front_page() eq 1 )" debug="true"]
  This function returns true
[/wpv-conditional]

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

This support ticket is created vor 6 Jahre, 9 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by ashleighP vor 6 Jahre, 9 Monate.

Assisted by: Beda.

Author
Artikel
#547645

I am trying to: hide breadcrumbs on home page using a conditional tag evaluating is_front_page

I visited this URL: hidden link

I expected to see: no breadcrumb

Instead, I got: Function isn't working. Debug won't even show the full data:

#################### wpv-conditional attributes #################### 
Array ( [if] => ( is_front_page() = 'true' ) [evaluate] => false [debug] => true ) 
#################### Debug information #################### 
-------------------- Original expression: ( is_front_page() = 'true' ) --------------------
#547771

I just tested that and it produces something like:

[wpv-conditional if="( is_front_page().id(undefined) eq 'true' )" debug="true"]Yes it's home[/wpv-conditional]

That is wrong and it has to be:

[wpv-conditional if="( is_front_page() eq 1 )" debug="true"]
  This function returns true
[/wpv-conditional]

Can you confirm this works for you as well?

I will then immediately add a BUG report.

The DOC already illustrates the issue with booleans:

If you expect the function to return a boolean, the value to check agains should be 1 or ‘1’ for true and 0 or ‘0’ for false.

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

But the Code is not created correctly by the GUI, see the ".id(undefined)" part.
That should not be present in Custom Functions and is the main issue here.

#548128

It's working for me now, thanks.

I missed that line in the docs.

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