Skip to content

Instantly share code, notes, and snippets.

@sb-relaxt-at
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sb-relaxt-at/f1c75954373c4564466f to your computer and use it in GitHub Desktop.
Save sb-relaxt-at/f1c75954373c4564466f to your computer and use it in GitHub Desktop.
<?php
/**
* This RedirectorPage differs from the regular one in so far, as it only redirects
* on the index action (no action specified) in contrast to the original one,
* which redirects on any immediate suburl
*
* @author Stephan Bauer <sb@relaxt.at>
*/
class BetterRedirectorPage extends RedirectorPage {
private static $hide_ancestor = 'RedirectorPage';
}
// Cannot extend RedirectorPage_Controller as this performs the redirect in its init method
class BetterRedirectorPage_Controller extends Page_Controller {
public function index() {
if ($link = $this->redirectionLink()) {
$this->redirect($link, 301);
return;
}
}
/**
* If we ever get this far, it means that the redirection failed.
*/
public function Content() {
return "<p class=\"message-setupWithoutRedirect\">" .
_t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
"</p>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment