[Resolved] Conditional Display of Content, Condition not equal but contains
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the user is using a custom shortcode and wanted to check if the value returned is not equal to a static value.
Solution:
This can be done by using the "ne" operator in our conditional shortcode.
Example
[wpv-conditional if="( '[wpv_contains haystack='testing' needle='test']' ne 'false' )"]
This support ticket is created 5 years, 12 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.
Tell us what you are trying to do?
Still struggling with the usage of the wpv_contains function. I managed to add the function to my frontend, so it will be read in the view. In debug mode I can see, that the function always delivers "false", whether the condition is met or not.
Is there any documentation that you are following?
After some more testing, I believe that the term "false" is never submitted, no matter whether a condition is met or not. But I cannot seem to find out, what exactly the shortcode delivers.
This condition works:
[wpv-conditional if="( '[wpv_contains haystack='testing' needle='test']' ne 'false' )"]
test output[/wpv-conditional]
I am really not sure how to solve this. Normally, it seems like an easy PHP function to me. But it simply does not work.
My issue is resolved now. Thank you! The problem was that the result from the function wpv_contains does not carry true or false but 0 or 1. That was the problem with my view. Thanks to Shane for helping me find a solution!
For anyone trying to work with this strpos() will never return TRUE so the issue with this code is "$pos !== true" which will never happen. You need to use "$pos == false" for this to work as it will only return nothing for true and false for FALSE.