Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

User log-in and redirect to different page


Reply


26 Posts   7513 Views

Avatar
borriej

Community Member, 267 Posts

6 August 2010 at 2:38am

Yes you can:

in security -> underneath the checkbox 'go to admin area'

it says:
'Or select a Page to redirect to'

select your redirect page.

Avatar
balder

Community Member, 14 Posts

6 August 2010 at 2:44am

Tried that, but when i select a page to redirect to the user logs in and is redirected to the frontend page i've choosen, while i want him to be redirected to that page but INSIDE the cms, so he can start editing his page as soon as he logs in. Does it make sense?
Thanks for your help :)

Avatar
Carbon Crayon

Community Member, 598 Posts

6 August 2010 at 2:48am

Hi Balder

all you need to do is change the way the redirect link is contructed, so this bit of code:

//Get the page that is referenced in the group
$Link = DataObject::get_by_id("SiteTree", "{$Group->LinkPageID}")->URLSegment;

Becomes this:

//Get the page that is referenced in the group
$Link = "admin/show/$Group->LinkPageID";

Untested but that should do it ;)

Aram

www.SSbits.com - SilverStripe Tutorials, Tips and other bits

Avatar
balder

Community Member, 14 Posts

6 August 2010 at 2:49am

Edited: 06/08/2010 2:50am

OK, i solved it thanks to this thread: http://www.silverstripe.org/general-questions/show/257647

----------------
The way to do this is to have the link be /admin/show/$ID of the page you want to redirect to. So I image you extract the Id from the TreeDropdownField and insert it into the redirector so change these lines:

$Link = DataObject::get_by_id("SiteTree", "{$Group->LinkPageID}")->URLSegment;

to this:

$ID = DataObject::get_by_id("SiteTree", "{$Group->LinkPageID}")->ID;

And this line:

Director::redirect(Director::baseURL() . $Link);

to this:

Director::redirect(Director::baseURL() . "admin/show/" . $ID);

------------------------

[edit]
You were faster :)
And that works by the way, so thanks a lot!

Avatar
Carbon Crayon

Community Member, 598 Posts

6 August 2010 at 2:50am

/\ My way is simple ;)

Avatar
balder

Community Member, 14 Posts

6 August 2010 at 3:00am

Just one more question to clean things up: when redirecting, the browser now displays a page with the following text:

-----------------
done
Redirecting to /myurl/admin/show/86... (output started on /.../mysite/code/CustomLogin.php, line 10)
--------------

And then redirects.
Is it possible not to display that page?

Avatar
Carbon Crayon

Community Member, 598 Posts

6 August 2010 at 3:26am

Hmm yea I have had that before, but not sure if/how you can get rid of it :s

Annoying...

Avatar
balder

Community Member, 14 Posts

6 August 2010 at 3:43am

Well that was easy :)
I just deleted the following on CustomLogin.php, line 10, which i guess was a leftover from the code i copied ;)
--------------
echo 'done';
--------------