CustomError
Description
This module allows the site admin to create custom error pages for 404 (not found), and 403 (access denied), without the need to create nodes for each of them.
Since the error pages are not real nodes, they do not belong a category term, they do not show in the search, and will not show up in node listings, or in Popular Content block.
Features
- Configurable page title and descriptions.
- Any HTML formatted text can be be put in the page body.
- There are no author and date/time headers as with normal nodes.
- Handles 404 and 403 errors at present. Drupal only allows those two errors to be assigned custom pages. The design of this module is flexible though and can accommodate future codes easily.
- The pages are themeable using the phptemplate_customerror() function in the template.php. The first argument is the error code (currently 403 or 404), and the message content.
- The messages can contain PHP, using one of two methods:
- By using the phptemplate_customerror() function (see above).
- By using the PHP checkbox in the settings.
- Users who are not logged in and try to access an area that requires login will be redirected to the page they were trying to access after they login.
- Allows custom redirects for 404s. For example if you had a page called foo and a page called xyz, then you moved them to a page called bar, and abc respectively, you can setup a redirect pair of:
^foo$ bar
^xyz$ abc
Users trying to access example.com/foo will be transparently redirected to example.com/bar.
Note that the first argument is a regexp, and the second argument is a path. You have to use one space between them, and enter each pattern on a line by itself.
Redirecting upon login
Here is an example of how to add custom PHP to a 403 to give the user the option to login then redirect them to what they were after.
<?php
global $user;
if ($user->uid == 0) {
print '<p>If your user account has access to this page, please <a href="/user?' . drupal_get_destination() . '">log</a>.</p>';
}
?>That way when there's a 403 they get redirected back to the page they were trying to access. The above should be better refined to fit "best practices", such as doing this in a template.php rather than code stored in the database, and probably call l() or url() so it works when clean URL's are disabled.
Thanks to: Andrew Berry (deviantintegral).
Installation
Please see the README.txt document included with this module for more details.
Author
Khalid Baheyeldin of 2bits.com.
The author can also be contacted for paid customizations of this module as well as Drupal consulting,
installation, development, and customizations.
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.1 | 2009-Mar-22 | 10.94 KB | Download · Release notes | Recommended for 6.x | |
| 5.x-1.2 | 2009-Mar-22 | 11.01 KB | Download · Release notes | Recommended for 5.x | |
| Development snapshots | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.x-dev | 2009-Oct-02 | 10.99 KB | Download · Release notes | Development snapshot | |
| 5.x-1.x-dev | 2009-Mar-20 | 11.02 KB | Download · Release notes | Development snapshot | |
