Way to keep edit mode to current page (rather than redirecting to home)?

Permalink
Is there a way to configure Concrete5 so that when a user signs in on a particular page to edit, that it remains on that page, rather than getting redirected to the home page.

I tried adding 'REDIRECT_TO_BASE_URL', false to my config file, but that appears to have a different purpose.

Is it possible, or is Concrete5 set to always begin at the home page when a user signs in?

 
wagdi replied on at Permalink Reply
wagdi
Have found another thread that answers this. the best answer by 'Tony' states-

"we're discussing adding an option to the dashboard so you can specify where you want a user to be redirected to after login, but in the meantime try this. Over-ride you c5root/concrete/controllers/login.php file by copying it to c5root/controllers/login.php, and then within the finishLogin() method, replace this: $this->redirect('/'); to point to where-ever you want to go after login."

SOURCE: http://www.concrete5.org/community/forums/customizing_c5/redirect_o...

OR you could try the 'Login Attribute Redirect' add-on-

It says-
"If you're running an Extranet or Intranet with concrete5 and you want to send specific users to specific destinations on login, this is the add-on for you. Perhaps each user has their own project page you want to send them to or maybe you want to force a certain group of users to visit the "news" page the next time they login, etc. This add-on creates an attribute for each user that defines where they will go on the next login.

use concrete5's user manager to assign a login location to all users by using groups or search terms.
redirect users anywhere, a local page - or even a 3rd party URL.
set it up to redirect the user JUST the next time they login, or EVERY time they login
works well with existing redirection options in concrete5 core, resetting to the default behavior after a single redirect if desired. "

SOURCE: http://www.concrete5.org/marketplace/addons/login-attribute-redirec...
michaelfm replied on at Permalink Best Answer Reply
michaelfm
If you are using a link to the login page in your theme you can use the following link instead. I've found that solution in the forum and used it in all my projects so far:

<a href="<?php  echo $this->url('/login', 'forward', $c->getCollectionID())?>" rel="nofollow"><?php echo t('Login')?></a>


After the user successfully logged in, he gets redirected to the previous page.
mkly replied on at Permalink Reply
mkly
That's awesome. Thanks.

I should point out for anyone reading this that you need to do a
global $c;
before you can do
$c->getCollectionID()
otherwise you can do
Page::getCurrentPage()->getCollectionID()
without the global $c; if you prefer.


I just tested and the login form uses a hidden form attribute "rcID" so if you are making a custom login form or block you can add
<input type="hidden" name="rcID" value="<?php echo $c->getCollectionID() ?>" />

to your custom login form and that should keep you on the same page after login.

EDIT: I should note that this would be for a login form that this placed on every page like in the header or sidebar.
lynxgeos replied on at Permalink Reply
Super awesome.

I'm not sure where I would declare the global page collection variable though ?
mkly replied on at Permalink Reply
mkly
You can do it anywhere above it in the view. Like you could just do this
<?php global $c; ?>
<a href="<?php  echo $this->url('/login', 'forward', $c->getCollectionID())?>" rel="nofollow"><?php echo t('Login')?></a>


EDIT: Oh shouldn't have to declare anything on the Page one I think. Doing
Class::method()

Is calling a "Pubic Static Method".http://php.net/manual/en/language.oop5.static.php...
If I'm wrong and you do get an error you can add
Loader::model('page');

above it.

That said I think the global $c is more common and may be preferred. Someone with a little more experience than me may need to chime in on that.