jwzumwalt Posted December 21, 2012 Share Posted December 21, 2012 I am a professional PHP programmer but have no experience with template driven application designs. I would like to add an edit button at the bottom of the product pages. Ideally the button would be displayed if the person is an admin but I would settle for it working with just my user ID or Name. I am using 1.4.9. I have pretty much figured out the code to do this except for the Smarty code to tell who the user is. Is there someone that is willing to mentor me through this? Thank you, Jan Zumwalt - SecurityWarehouseStore.com Link to comment Share on other sites More sharing options...
math_php Posted December 24, 2012 Share Posted December 24, 2012 Hi Jan, Do you want to display this button in the Front or in the Back Office ? If you have the code then in tpl add this {if isset($jan_edit_button)} {$jan_edit_button} {/if} In your php you put something like this smarty_assign('jan_edit_button',$edit_button); Remember that tpl is cached then if your result does not appear, dump smarty compile folder (keep index.php in it) Not sure if it will help you, anyway merry Christmas. Best regards 1 Link to comment Share on other sites More sharing options...
jwzumwalt Posted December 25, 2012 Author Share Posted December 25, 2012 (edited) Thank yo for your reply I would like an "edit" button to appear on each product page in the front office - but only if it is me or an admin. When I am working with a customer I sometimes see a mistake and would like to go right to the product edit screen to fix it. I have a snippet of code that will take me to the edit screen but have been unable to figure out how the template system is saving user settings/validation or identification. In PHP pseudo code I am trying to do this... If (is user admin) { show edit button->link to edit; } As I said earlier, I have not used the Smarty template code before but with a "normal" PHP program either a cookie, session var, or db value would tell if the user has a admin account. Then we would do something like this... If (isset($_SESSION['admin'])) { echo '<INPUT type="button" value="Edit" onClick="window.location='http://www.test.com/GET values'">'; } I pretty much have things figured out except the logic in red. I only have myself to worry about in my shop but would like to provide a better solution to share with others. Thanks again for any assistance you can offer. Edited December 26, 2012 by jwzumwalt (see edit history) Link to comment Share on other sites More sharing options...
math_php Posted December 26, 2012 Share Posted December 26, 2012 Hi I have not really tested but try this $cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600)); $admin_cookie = new Cookie('psAdmin', '', $cookieLifetime); if $admin_cookie->isLoggedBack() Best regards Link to comment Share on other sites More sharing options...
describe Posted January 22, 2013 Share Posted January 22, 2013 Is there any solution for this topic? thanks Link to comment Share on other sites More sharing options...
jwzumwalt Posted January 22, 2013 Author Share Posted January 22, 2013 No, there has not been a solution yet. I have taken another look a couple of times but have yet to follow the whole problem. I have ended up fixing several other problems instead. 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