lordmark200 Posted December 9, 2011 Share Posted December 9, 2011 Hi all, By default the User Account block only displays when a user is logged in. I wanted to adapt it so that if a user isn't logged in it will display a login form. I managed to get this working by modifying the myaccount block but I'm not sure if I approached it in the right way and would welcome any advice. Firstly I edited modules/blockmyaccount/blockmyaccount.php: Changing: public function hookLeftColumn($params) { global $smarty; if (!$params['cookie']->isLogged()) return false; $smarty->assign(array( 'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')), 'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')), 'HOOK_BLOCK_MY_ACCOUNT' => Module::hookExec('myAccountBlock') )); return $this->display(__FILE__, $this->name.'.tpl'); } to public function hookLeftColumn($params) { global $smarty; if (!$params['cookie']->isLogged()) return $this->display(__FILE__, $this->name.'2.tpl'); $smarty->assign(array( 'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')), 'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')), 'HOOK_BLOCK_MY_ACCOUNT_LOGIN' => Module::hookExec('myAccountLoginBlock') )); return $this->display(__FILE__, $this->name.'.tpl'); } Then I created a copy of blockmyaccount.tpl and called it blockmyaccount2.tpl and replaced the contents with the form from authentication.php <div class="block myaccount"> <h4>Account Holders</h4> <div class="block_content"> <form action="authentication.php" method="post" id="login_form" class="std"> <p class="text"> <label for="email">E-mail address</label> <span><input type="text" id="email" name="email" value="" class="account_input" /></span> </p> <p class="text"> <label for="passwd">Password</label> <span><input type="password" id="passwd" name="passwd" value="" class="account_input" /></span> </p> <p class="submit"> <input type="submit" id="SubmitLogin" name="SubmitLogin" class="button" value="Log in" /> </p> <p class="lost_password"><a href="password.php">Forgot your password?</a></p> <p class="registerforaccount"><a href="authentication.php"><strong>Register Here</strong></a></p> </form> </div> </div> I have since edited more of the php file and config file to make it a completely separate module from blockmyaccount so that my changes aren't overwritten if I update Prestashop. It all seemed a little too easy, surely there's something I've done wrong? Many thanks Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 9, 2011 Share Posted December 9, 2011 Hello! Seems to be correct, but you will know for sure when you test it. Link to comment Share on other sites More sharing options...
ill7 Posted December 22, 2011 Share Posted December 22, 2011 Hello, I have proved the modifications that lordmark200 wrote. Apparently it works correctly, but not shows correctly. I have attache 2 pictures to show it. First pictures shows when I click on "Enter" in the top-right of Prestashop. Second pictures shows when I´m in the index.php of Prestashop. Do you know what could be the solution ? Thanks in advance Regards Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 28, 2011 Share Posted December 28, 2011 Hello! You need to set up the CSS styles correctly and check if the HTML code is correct. Link to comment Share on other sites More sharing options...
publitesa Posted January 18, 2012 Share Posted January 18, 2012 Hi. Thanks for your adaption! I'm trying it and when I log in with correct user and password, it goes to autenticacion.php and it doesn't log. So I have to log in the standar page. Why doesn't log in correctly from my block? Link to comment Share on other sites More sharing options...
CartExpert.net Posted January 25, 2012 Share Posted January 25, 2012 Hello, from the amount of information you have provided, we can't tell where the problem is. 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