cjx2240 Posted September 7, 2017 Posted September 7, 2017 I've made a temporary new page on a new template, I want to redirect all traffic to this for a while, whilst making the url just be "/", what's the cleanest way to do this please?
abdus Posted September 7, 2017 Posted September 7, 2017 @cjx2240, I'm not sure if this is the best way, but hey it works. Put this in your /site/ready.php wire()->addHookBefore('Page::render', function (HookEvent $e) { // requested page (not the one being rendered) $page = $e->page; // skip admin pages if (strpos($e->input->url, $e->config->urls->admin) === 0) return; // force redirect to homepage if ($page->id != 1) { $e->session->redirect('/'); } }); And in your home template, put this at the beginning <?php namespace ProcessWire; $splashPage = $pages->get(1353); echo $splashPage->render(); return $this->halt(); 4
cjx2240 Posted September 7, 2017 Author Posted September 7, 2017 Thanks @abdus that looks great. Actually I was in a rush and I decided I would have to accept having a "/holding-page" and just used $session->redirect() but if I get a chance I will definitely change to this so I can be on "/"
cst989 Posted January 11, 2018 Posted January 11, 2018 I used this for a while and it was very helpful. But it isn't working for me anymore, has anything changed in a recent PW update that would stop the ready.php hook above working?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now