[PKP Core] How to customize 404 page and integrate it to the theme without modifying the core?

Here is how my journal handles 404 errors :

And this is how I want it to appear :

In short, I want the 404 error to be redirected to a dedicated custom page.

Alas, this seems impossible, unless I commit the sin to modify the core code.

As advised on this forum post : How to insert hyperlinking anchors throughout an OJS 3.1.2 site (system links inclusive)? - #11 by teog one can simply modify the /lib/pkp/classes/core/Dispatcher.php and replace the line “header(‘HTTP/1.0 404 Not Found’);” by, for example, “header(‘Location: /404’)” (with ‘/404’ as the url of a dedicated custom page) to get the result from my second screenshot.

Well doing that even though it seems very simple and convenient is simply out of question for the project I am working on.

I can’t find a way to do that via a plugin neither, the only solution I can think of is to fix it in a future PKP lib release. But I can’t find any prospect of such feature in the PKP Roadmap.

Really it baffles me, all other journal somehow manage their 404 error with some dedicated page with links to other pages of the website so that the visitor is not stuck in a dead end, so why aren’t we fixing this horrible handle404 function ?

Hi @marc

Please move it then to the support section, let me know if you still want me to change the content of the post.

1 Like

Hi @ErwanBo,

Looks like the topic has been switched to support, but in order to help others assist with support can you please indicate your OJS version (e.g. 3.3.0-13) as well as the version and name of the theme you’re using.


PKP Team

Hello @rcgillis ,

My OJS version is 3.3.0-8

The problem seems to occur regardless of the theme used, so let’s say the default theme.

Have you tried to do it, e.g., from a generic plugin. Say, extend Dispatcher, override handle404(), hook into Dispatcher::dispatch and replace the dispatcher with the extended one through $request->setDispatcher()? But I must confess that don’t know if it works.

This topic was automatically closed after 17 hours. New replies are no longer allowed.