Tell us what you are trying to do?
implement a snippet within a conditional if
Is there any documentation that you are following?
https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/
the "b.png" is the snippet, I followed your example, the output is '1' for testing purposes
the "c.png" is the view code, always testing for '1'. the view works fine if I remove this particular line testing for search() eq '1'. but the condition is never satisfied because the enclosed output never occurs
Also I tested to see that [search] returns '1' (or the real value from the custom field)
I also registered search as a 3rd party shortcode arguments, thinking that might be necessary
I need to implement some quite complex code in the snippet, one I get this simple demo working
Thanks for your help
Hello and thank you for contacting the Toolset support.
You have registered a shortcode to be used in the condition, but you actually used a function in the condition:
[wpv-conditional if="(search() eq '1')"]
When you should use the shortcode for it:
[wpv-conditional if="( '[search]' eq '1')"]
If you want to use the function, you will need to register the function, instead of the shortcode, in the Toolset Settings.
https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/
You will also need to wrap it in single quotes:
[wpv-conditional if="( 'search()' eq '1')"]
It is also safer if you move the following line before your code like so:
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_shortcode('search', 'search');
// etc...