![]() |
| Frontier Tutorials / Writing an ObjectNotFoundHandler / Bonus: The "Penultimate" Master Script |
|
|---|
This page contains a more generic version of the master script presented on the Misdirected URLs page. Here's the script:
|
|---|
Only the block where the script calls Mode 2 and Mode 3 scripts has changed.
Instead of explicitly calling each subsidiary script from within the master script, it looks for them in a subtable of the #tools table named "ONFH_2and3". It expects each entry to be either a script or an address that can be resolved to a script.
As a result, you can install and remove ONFH scripts without modifying the master script in any way.
Install the master #objectNotFoundHandler script from this page in your website.
Create a subtable in your #tools table named "ONFH_2and3".
Copy Mode 2 and Mode 3 ONFH handlers (such as the Bonus handlers in this tutorial) into the "ONFH_2and3" table, or enter the addresses of such handlers in the table (e.g., @xfile.mainResponder.ObjectNotFoundHandler).
If you desire, you can create a #notFoundText entry (directive) in your site (or multiple ones at various levels). If you do so, this script will insert the missing path in the page table as whatObjectNotFound, to make it available in #notFoundText. It will then return the text of #notFoundText, after calling html.processMacros on it. For the #notFoundText entry shown in the Mode 1 Example, this would create a hot-link to the site outline (if there were one) and expand the "{whatObjectNotFound}" and "{string( forms^.search )}" macros we inserted in the text.
If you do not create a #notFoundText entry, this script returns a very simple file-not-found page text.
|
|---|
I call this the penultimate script because it omits something: it doesn't support operation within Manila websites. Because Manila uses an ONFH for its own purposes, you would have to modify this script for use in Manila websites.
In short, the modified script will follow this pattern:
|
|---|
For a full discussion of why this is required and how it works, see Jason Levine's article, Manila and #objectNotFoundHandler.