This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Daniel81
Daniel81

Anyone know how to return a 404 from a Plugin? Not a component where you can use:

return Response::make( $this->controller->run('404'), 404 );

but a plugin? My heads gone blank & I've got a headache ;)

PS, this is the exception I get if I try the above in a plugin:

Maximum execution time of 30 seconds exceeded
/Applications/MAMP/htdocs/october/modules/system/classes/ErrorHandler.php line 105

Last updated

alxy
alxy

Where in a plugin would you do that?

Daniel81
Daniel81

I'm assuming in the onRun(), at least that's where I've put it

alxy
alxy

? yeah, makes sense there. But you said you don't want it in component, but somewhere else in the Plugin? So where exactly? (Or, in other words: I dont get your question. It just doesnt make sense to return a 404 from Plugin.php for example.)

Daniel81
Daniel81

Ok, I have a plugin that's constantly running in the background, think of it as a central plugin linking to all other plugins I've built, one of which being a "Content Scheduler" for contents, partials, pages etc.

Now, if a page/url is in the scheduler i.e the page is not live but is scheduled to be so, and someone hits that url, I need the plugin to throw a 404 for that page, as it's not live yet, it's scheduled.

The scheduler does have a component that gets added into pages for contents & partials, but I don't want to have to place it in all pages that need scheduling, hence why I have a central plugin that runs all the time in the background to handle this sort of thing.

Does that make sense?

Daniel81
Daniel81

I can return the default 404 page using return Response::make( View::make( 'cms::404' ), 404 ); just can't figure out how to return the custom theme 404 page?

Seems to be an issue when calling the $this->controller->run('404'), it seems to cause the application to stall throwing the timeout error above.

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.