Last active
August 29, 2015 14:04
-
-
Save sb-relaxt-at/f1c75954373c4564466f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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