raintpl3 icon indicating copy to clipboard operation
raintpl3 copied to clipboard

Problem while creating a tag

Open patrickse opened this issue 10 years ago • 3 comments

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

patrickse avatar Mar 31 '14 11:03 patrickse

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.

patrickse avatar Mar 31 '14 14:03 patrickse

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.

feulf avatar Mar 31 '14 16:03 feulf

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.

keskad avatar Apr 01 '14 08:04 keskad