Search the Community
Showing results for tags 'wire404exception'.
-
Greetings! For our PW project we use markup regions and, for one template, url segments. The documentation recommends throwing a new Wire404Exception() from the template when the code concludes that the url segments from the request are invalid, and so we do. However, the 404 page is not displayed properly. Viewing the page source in the browser we can see that the original, unmodified markup region contents from our _init.php file is prepended to the correct html output, messing the whole page up. Any advice is greatly appreciated.
- 3 replies
-
- wire404exception
- markup regions
-
(and 1 more)
Tagged with:
-
I'm using "throw new Wire404Exception();" in my template, it worked fine. After Migrating to an other server and Upgrading to PW 3.0.62 I got an Error "Class 'Wire404Exception' not found" . I spent the day yesterday unsuccessfully to understand the reason. Is there any reason, why PW can't find this class? The Exceptions.php in wire/core exists. I beg your pardon, if this topic should be discussed here yet - the search items 'Wire404Exception' and 'not found' leed to many other results not related to the class itself.
-
Dear Communiy, My template basic-page does have URL segments activated. The segments are used to handle a different URL for the files attached. If a file is not found a Wire404Exception() is thrown. Sadly PagePathHistory does not handle it correctly (in my opinion) and old URLs no longer are redirected to the new ones. wire/modules/PagePathHistory.module:117 /** * Hook called upon 404 from ProcessPageView::pageNotFound * */ public function hookPageNotFound(HookEvent $event) { $page = $event->arguments[0]; // If there is a page object set, then it means the 404 was triggered // by the user not having access to it, or by the $page's template // throwing a 404 exception. In either case, we don't want to do a // redirect if there is a $page since any 404 is intentional there. if($page && $page->id) return; [...] The documentation makes sense here but is the opposite of the desired effect. Only solution for my problem was to disable the if-Statement, is there a better way to do this?
-
Hi! I rebuilding site from another CMS and need to redirect some old pages to new ones. Old scheme of urls is site.com/index.php?id=123 I have this in _init.php: $id = (int)$input->get->id; if ($id > 0) { $redirect_page = wire('pages')->get("parent=/tools/old2new/, template=old2new-redirect, name=$id"); if ($redirect_page instanceof NullPage) { throw new Wire404Exception(); } else { $url = $redirect_page->redirect_to->url . $redirect_page->param; wire('session')->redirect($url); } } So, Wire404Exception() -- throw me this: Fatal error: Exception: (in \www\site\templates\_init.php line 21) #0 \www\wire\core\TemplateFile.php(139): require() #1 [internal function]: TemplateFile->___render() #2 \www\wire\core\Wire.php(359): call_user_func_array(Array, Array) #3 \www\wire\core\Wire.php(317): Wire->runHooks('render', Array) #4 \www\wire\modules\PageRender.module(337): Wire->__call('render', Array) #5 \www\wire\modules\PageRender.module(337): TemplateFile->render() #6 [internal function]: PageRender->___renderPage(Object(HookEvent)) #7 \www\wire\core\Wire.php(359): call_user_func_array(Array, Array) #8 \www\wire\core\Wire.php(317): Wire->runHooks('renderPage', Array) #9 \www\wire\core\Wire.php(381): Wire->__call('renderPage', Array) #10 \www\wire\core\Wire.php(381): PageRender->renderPage(O in \www\index.php on line 216 But if I use exception from another template it working fine and render 404 page. Please help to fix it and maybe some suggestion to "redirect" code?