I just wrote a plugin ( my first ) which is supposed to evaluate to a Boolean so that it can be used in a if statement, similar to {if logged_in}.
Here is the test template:
{if {exp:keyauth:auth}}
Show secret data
{/if}
no access for you
When the plugin returns true everything works correctly but when the plugin returns false I get PHP errors in Template.php.
Parse error: parse error in C:\xampp\htdocs\rtrain\trunk\training\system\expressionengine\libraries\Functions.php(650) : eval()’d code on line 1
Is there another way that I should be doing this?
You could make it a tag pair and use $this->EE->functions->prep_conditionals() - http://ellislab.com/expressionengine/user-guide/development/reference/functions.html.
Template code would look like:
{exp:keyauth:auth}
{if auth}
.... more ...
{/if}
{/exp:keyauth:auth}Psuedo PHP plugin code:
public function auth()
{
$conditionals = array('auth' => TRUE);
return $this->EE->functions->prep_conditionals($this->EE->TMPL->tagdata, $conditionals);
}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.