raintpl3
raintpl3 copied to clipboard
Problem while creating a tag
Hi,
I am trying to implement a Role-Based website. A few parts of my templates should be hidden when a user with a certain role enters the page. I´ve tried to use tags for this.
{hasRole("Admin")}
Status
Time
{/hasRole}
If the user has the role admin the content will be visible otherwise its not rendered onto the page.
I´ve created the extension and passed the regexp. But I am actually failing because it looks like that tags are no intended to use multiple lines of code.
Is there any other chance to achieve this behaviour without using the {if=""}-clause?
Hope you can help me...
Patrick
I´ve solved my problem. I am now using the PluginFramework and replacing the tags with a call to a static function outside the template.
Now it works quite good.
Great!
From my iPhone
On Mar 31, 2014, at 10:18 AM, patrickse [email protected] wrote:
I´ve solved my problem. I am now using the PluginFramework and replacing the tags with a call to a static function outside the template.
Now it works quite good.
— Reply to this email directly or view it on GitHub.
In my framework I'm just checking permissions and passing it to variable eg. template -> push('isAdmin', true);
and checking {if="$isAdmin"} ... {/if}
. It's better to separate logic code from template, so you should'nt use permissions checking functions inside of template.