Visiedo Posted February 4, 2013 Share Posted February 4, 2013 (edited) Hi, I was looking for a way to redirect a user to the original page after the login, avoiding the default behavior from prestashop, i.e. redirect to the "my-account" page. There are several threads on the topic, but at the end I could not find anything that fulfilled my reqs. and finally come with this method. I would like to get your opinions, specially if you believe it won't work under some circumstances, since it is still not fully verified. My [simple] requirements: Redirect a user to the original page after signing in, when using the login link at the "blockuserinfo". No exceptions in any page Should work for both HTTP and HTTPS The solution: Edit the "blockuserinfo.tpl", and change this part at the end of the file (lines 56-60 in 1.5.3) {if $logged} <a href="{$link->getPageLink('my-account', true)}" class="account"><span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span></a> <a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Log me out' mod='blockuserinfo'}" class="logout">{l s='Log out' mod='blockuserinfo'}</a> {else} <a href="{$link->getPageLink('my-account', true)}" class="login">{l s='Log in / Join us!' mod='blockuserinfo'}</a> {/if} by {if $logged} <a href="{$link->getPageLink('my-account', true)}" class="account"><span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span></a> <a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Log me out' mod='blockuserinfo'}" class="logout">{l s='Log out' mod='blockuserinfo'}</a> {else} <a href="{$link->getPageLink('authentication', true)}?back={if $smarty.server.SERVER_PROTOCOL|strstr:"https"}https://{else}http://{/if}{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" class="login">{l s='Log in / Join us!' mod='blockuserinfo'}</a> {/if} I replace the call to 'my-account' by a direct call to the 'authentication' controller, including the full URL of the current page in the "back" parameter. It is important to include also the protocol "http:// or https://", otherwise the it will assume that the value for "back" is the name of a controller, and will result in a redirection to: index.php?controler='your URL' returning a 404. I am very interested on your opinions, I hope you find it correct and useful ;-) Please also feel free to suggest improvements Edited February 5, 2013 by Visiedo (see edit history) 3 Link to comment Share on other sites More sharing options...
theca007 Posted December 10, 2014 Share Posted December 10, 2014 thx for this code Link to comment Share on other sites More sharing options...
pierrelouis.silliere Posted May 13, 2015 Share Posted May 13, 2015 Awesome ! I was looking for this solution, thanks ! Link to comment Share on other sites More sharing options...
JavierUpn Posted June 10, 2016 Share Posted June 10, 2016 Excuse me, which folder you put the files that linked the method "$link->getPageLink('myfile')" ??? 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