hakeryk2 Posted February 13, 2016 Share Posted February 13, 2016 Hello community, Is there is any chance to get some code that will do something only for logged administrator in front office? Something like: if is_admin(1) { some code } else { another code } IE display "edit this" only for admins in product.tpl file? Link to comment Share on other sites More sharing options...
ukvapeclub Posted February 25, 2016 Share Posted February 25, 2016 I've recently done something like this, firstly you'll need to pass a variable to Smarty from whatever module you're playing with, for example: $this->cookie = new Cookie('psAdmin'); if (isset($this->cookie->id_employee) && $this->cookie->id_employee != ''){ $employee = new Employee($this->cookie->id_employee); if ( $employee->isSuperAdmin() ) { $this->context->smarty->assign('issuperadmin', true); } } Then you can use {if $issuperadmin}<DO SOME STUFF>{/if}in your template. Credit goes to the "Ninja Customer" module for this, that's what I based the above code on. 1 Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 28, 2016 Author Share Posted February 28, 2016 2 days ago when I found Ninja Customer module I tried to get the code from there to do what I want to do ... but You made it first I will try your code in next 2 days and I will let You know if it works or not. Thank You anyway. 1 Link to comment Share on other sites More sharing options...
grsinternet Posted November 19, 2019 Share Posted November 19, 2019 On 2/28/2016 at 7:52 PM, hakeryk2 said: 2 days ago when I found Ninja Customer module I tried to get the code from there to do what I want to do ... but You made it first I will try your code in next 2 days and I will let You know if it works or not. Thank You anyway. has it worked? For which PS version this code fits? Thank you! Link to comment Share on other sites More sharing options...
grsinternet Posted November 19, 2019 Share Posted November 19, 2019 On 2/25/2016 at 8:38 PM, ukvapeclub said: I've recently done something like this, firstly you'll need to pass a variable to Smarty from whatever module you're playing with, for example: $this->cookie = new Cookie('psAdmin'); if (isset($this->cookie->id_employee) && $this->cookie->id_employee != ''){ $employee = new Employee($this->cookie->id_employee); if ( $employee->isSuperAdmin() ) { $this->context->smarty->assign('issuperadmin', true); } } Then you can use {if $issuperadmin}<DO SOME STUFF>{/if} in your template. Credit goes to the "Ninja Customer" module for this, that's what I based the above code on. where to put this code in PS 1.7? In smarty I can't do this... Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now