17691 Posts in 4607 Topics by 2180 members
General Questions
SilverStripe Forums » General Questions » Could someone tell me what the purpose of the first few lines of Controller::redirect method are?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1492 Views |
-
Could someone tell me what the purpose of the first few lines of Controller::redirect method are?

4 September 2009 at 8:31am Last edited: 4 September 2009 9:24am
Running into a problem where I am encountering the error message produced from the first few lines of the Controller::redirect() method - and wondering if someone could explain the rationale behind this logic?
if($this->response->getHeader('Location')) {
user_error("Already directed to " . $this->response->getHeader('Location') . "; now trying to direct to $url", E_USER_WARNING);
return;
}Just curious, as I'm finding it difficult to come up with a work around given these lines.
Thanks
UPDATE: Never mnd - this doesn't effect live deployment as it's only a warning, so commenting it from my local development machine...
-
Re: Could someone tell me what the purpose of the first few lines of Controller::redirect method are?

5 September 2009 at 7:02pm Last edited: 5 September 2009 7:03pm
FYI Its to prevent having Director::redirect() commands redirecting the user multiple times.
-
Re: Could someone tell me what the purpose of the first few lines of Controller::redirect method are?

7 September 2009 at 2:39am
So how would you approach only redirecting the user to the first appearing Director::redirect?
I'm getting the 'Already redirected' warning, and have no clue of how to get around it (I'm building a 'maintenance offline' settings script):
$bolMaintenanceRedirect = true;
if (Member::currentUser()) {
if(Member::currentUser()->isAdmin()) {
$bolMaintenanceRedirect = false;
}
}
if ($bolMaintenanceRedirect){
if (Director::urlParam("Controller") != 'Security') {
if (Director::urlParam("Action") != 'login') {
Director::redirect('downformaintenance.html');
}
}
} -
Re: Could someone tell me what the purpose of the first few lines of Controller::redirect method are?

7 September 2009 at 9:47am
Is it calling that function twice? If you put a Debug::message("test"); inside that last if does it show twice?. You could be redirecting as well as SilverStripe doing something with the security redirect
-
Re: Could someone tell me what the purpose of the first few lines of Controller::redirect method are?

8 September 2009 at 9:49pm
I was looking for a way to overrule any other redirects that would have been set before. I thought maybe there would be a method for that?
I ended up by fixing this by setting some preferences, and a couple of if statements.Thanks for the fast reply!
| 1492 Views | ||
|
Page:
1
|
Go to Top |



