21287 Posts in 5733 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2192 Views |
-
BackURL login / registring

28 September 2010 at 4:12am
I've extended my SilverStripe installation with a user registration page. I've altered a BackURL variable to the links to the login and regsitry pages.
However, how can I include the BackURL in my altered login template to include a message that they can register for an account?
themes/mytheme/templates/Layout/Security_login.ss
$Content
Login below or <a href="{$BaseHref}register?BackURL={$BackURL}">register for an user account</a>.
$Form
<a href="{$BaseHref}register?BackURL={$BackURL}">Register for an user account</a>The BackURL is added to the Form itself, but not to the 'register user account' links.
I've tried adding a CustomLoginForm, but the BackURL information isn't available in the Security_login.ss (as it will probably need to be added to the Controller but I can't find the Form Controller.
<?php
class CustomLoginForm extends MemberLoginForm {
public function BackURL() {
if(isset($_REQUEST['BackURL'])) {
return $_REQUEST['BackURL'];
} else {
return Session::get('BackURL');
}
}
}Any help would be appreciated.
-
Re: BackURL login / registring

28 September 2010 at 4:22am
I've used...
Security::set_default_login_dest('urlsegment');
to set a site wide login destination, does this help?
-
Re: BackURL login / registring

28 September 2010 at 5:26am
No, that's not what I meant. There is a login link on each page. After a visitors successfully logs in (or chooses the register option on the login page) I want them redirected back to the page on which they clicked the login link.
-
Re: BackURL login / registring

28 September 2010 at 5:32am
how about something like the following in Page::init()?
Session::set('BackURL',$this->Link());
-
Re: BackURL login / registring

28 September 2010 at 7:13am
Solution turned out to be quite simple, I've ended up putting the BackURL function in the Page_Controller so it can be included into the Security_login.ss template.
class Page_Controller extends ContentController {
public function BackURL() {
if(isset($_REQUEST['BackURL'])) {
return $_REQUEST['BackURL'];
} else {
return Session::get('BackURL');
}
}
}
| 2192 Views | ||
|
Page:
1
|
Go to Top |


