Skip to content

Commit

Permalink
Merge pull request #2 from micschk/master
Browse files Browse the repository at this point in the history
Fixing #1: making paritals work on /home/ URLSegment
  • Loading branch information
ryanwachtl committed Jan 18, 2015
2 parents ee586ad + 9ceb9b8 commit cf65cc7
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 cf65cc7

Please sign in to comment.