Throw a 404 error
Permalink
How do I throw a 404 error, I want to do this from a block.
In Concrete 5.6 I could do:
$v = View::getInstance();
$v->render('/page_not_found');
But this doesn't seem to work anymore, I get the following error:
include(/Library/WebServer/Documents/site/concrete/views/.php): failed to open stream: No such file or directory
Does anyone know the best method?
Many thanks
In Concrete 5.6 I could do:
$v = View::getInstance();
$v->render('/page_not_found');
But this doesn't seem to work anymore, I get the following error:
include(/Library/WebServer/Documents/site/concrete/views/.php): failed to open stream: No such file or directory
Does anyone know the best method?
Many thanks
Hi Mnkras
Thanks for your response, unfortunately I get a Call to undefined method error. I am trying this from a block rather than a page though.
Many thanks
Thanks for your response, unfortunately I get a Call to undefined method error. I am trying this from a block rather than a page though.
Many thanks
Below is a code snippet to throw a 404 error from within a Block.
The important part is the $c...
As part of a function within a block...
Sorry to bring back this old post, but since I just figured it out and this is the place Google keeps sending me to, below
The important part is the $c...
$c = \Page::getCurrentPage(); $c->getPageController()->replace('/page_not_found');
As part of a function within a block...
public function action_details($slug) { $release = $this->getReleaseService()->getReleaseBySlug($slug); if ($release == null) { $c = \Page::getCurrentPage(); $c->getPageController()->replace('/page_not_found'); return; } ...
Sorry to bring back this old post, but since I just figured it out and this is the place Google keeps sending me to, below
where $this is an instance of PageController