Skip to content

Commit

Permalink
Fixing #1: making paritals work on /home/ URLSegment
Browse files Browse the repository at this point in the history
Preventing the redirection from /home/ to / if requesting a partial
  • Loading branch information
micschk committed Jan 18, 2015
1 parent ee586ad commit 9ceb9b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion code/FoundationInterchangeControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ public function onAfterInit() {
$vars = $controller->request->getVars();
$partial = (isset($vars[$this->template_param]) && $vars[$this->template_param] != "") ? $vars[$this->template_param] : false;
if ($partial) {
// render partial
$controller->response->setBody($controller->renderWith($partial));
// Prevent redirection of /home/ to / if requesting a partial of homepage,
// should happen before $controller->response->output();
if($this->owner->URLSegment=='home'){
$this->owner->response->removeHeader('Location');
$this->owner->response->setStatusCode(200);
}
// output to browser
$controller->response->output();
exit();
}
Expand All @@ -19,4 +27,4 @@ public function InterchangePartial($template) {
return $this->owner->Link() . '?' . $this->template_param . '=' . $template;
}

}
}

0 comments on commit 9ceb9b8

Please sign in to comment.