Throw a 404 error

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();

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

View Replies:
Mnkras replied on at Permalink Reply
in 5.7 from your controller you can do:


where $this is an instance of PageController
bvcreative replied on at Permalink Reply
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
greg403 replied on at Permalink Reply
Below is a code snippet to throw a 404 error from within a Block.
The important part is the $c...

$c = \Page::getCurrentPage();

As part of a function within a block...

public function action_details($slug)
        $release = $this->getReleaseService()->getReleaseBySlug($slug);
        if ($release == null) {
            $c = \Page::getCurrentPage();

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