You are here

README.txt in Customerror 5

Same filename and directory in other branches
  1. 8 README.txt
  2. 6 README.txt
  3. 7 README.txt
Copyright 2005 http://2bits.com

Description
-----------
This module allows the site admin to create custom error pages for
404 (not found), and 403 (access denied).

Since the error pages are not real nodes, they do not belong a category
term, and hence will not show up in node listings.

It also allows the site admin to setup 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.

Features
--------
* Configurable page title and descriptions.
* Any HTML formatted text can be be put in the page body.
* 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.
  (Requires a minor change to common.inc, see INSTALL.txt for details).

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 (http://drupal.org/user/71291 deviantintegral).

Database
--------
This module does not require any new database tables to be installed.

Installation:
-------------
Please see the INSTALL.txt document for details.

1. Copy the customerror.module to the Drupal modules/ directory.

2. Go to Administer -> Build -> Modules
   - Enable the customerror module, click on Save

3. Configure the module:
   - Go to Administer -> Site configuration -> Custom error
   - Enter any title and description you want for the 404 (not found)
     and 403 (access denied) pages.
   - You can use any HTML tags to format the text.
   - Ensure the Enable checkbox is checked. That sets or unsets the Error
     Reporting settings for you.

4. Configure Error reporting
   - Go to Administer -> Site configuration -> Error reporting
   - For 403 (access denied), enter the value:
       customerror/403
   - For 40 (not found), enter the value:
       customerror/404

5. Test your error pages.
   - Copy your present admin page url.
   - Try to go to a non-existent Drupal page on your site.
   You should see your custom error page for 404 (not found) page.

   - Log out from your site.
   - Paste the admin page url and try to go there.
   You should see your custom error page for 403 (access denied) page.

Bugs/Features/Patches
---------------------
If you want to report bugs, feature requests, or submit a patch, please do so
at the project page on the Drupal web site.
http://drupal.org/project/customerror

Author
------

Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)

If you use this module, find it useful, and want to send the author
a thank you note, then use the Feedback/Contact page at the URL above.

The author can also be contacted for paid customizations of this
and other modules.

File

README.txt
View source
  1. Copyright 2005 http://2bits.com
  2. Description
  3. -----------
  4. This module allows the site admin to create custom error pages for
  5. 404 (not found), and 403 (access denied).
  6. Since the error pages are not real nodes, they do not belong a category
  7. term, and hence will not show up in node listings.
  8. It also allows the site admin to setup redirects for 404s. For example
  9. if you had a page called foo and a page called xyz, then you moved them
  10. to a page called bar, and abc respectively, you can setup a redirect pair
  11. of:
  12. ^foo$ bar
  13. ^xyz$ abc
  14. Users trying to access example.com/foo will be transparently redirected
  15. to example.com/bar.
  16. Features
  17. --------
  18. * Configurable page title and descriptions.
  19. * Any HTML formatted text can be be put in the page body.
  20. * Handles 404 and 403 errors at present. Drupal only allows those two
  21. errors to be assigned custom pages. The design of this module is
  22. flexible though and can accommodate future codes easily.
  23. * The pages are themeable using the phptemplate_customerror() function
  24. in the template.php. The first argument is the error code (currently
  25. 403 or 404), and the message content.
  26. * The messages can contain PHP, using one of two methods:
  27. - By using the phptemplate_customerror() function (see above).
  28. - By using the PHP checkbox in the settings.
  29. * Users who are not logged in and try to access an area that requires
  30. login will be redirected to the page they were trying to access after
  31. they login.
  32. (Requires a minor change to common.inc, see INSTALL.txt for details).
  33. Redirecting upon login
  34. ----------------------
  35. Here is an example of how to add custom PHP to a 403 to give the user the
  36. option to login then redirect them to what they were after.
  37. global $user;
  38. if ($user->uid == 0) {
  39. print '

    If your user account has access to this page, please log.

    ';
  40. }
  41. ?>
  42. That way when there's a 403 they get redirected back to the page they were trying to access.
  43. The above should be better refined to fit "best practices", such as doing this in a template.php
  44. rather than code stored in the database, and probably call l() or url() so it works when clean
  45. URL's are disabled.
  46. Thanks to: Andrew Berry (http://drupal.org/user/71291 deviantintegral).
  47. Database
  48. --------
  49. This module does not require any new database tables to be installed.
  50. Installation:
  51. -------------
  52. Please see the INSTALL.txt document for details.
  53. 1. Copy the customerror.module to the Drupal modules/ directory.
  54. 2. Go to Administer -> Build -> Modules
  55. - Enable the customerror module, click on Save
  56. 3. Configure the module:
  57. - Go to Administer -> Site configuration -> Custom error
  58. - Enter any title and description you want for the 404 (not found)
  59. and 403 (access denied) pages.
  60. - You can use any HTML tags to format the text.
  61. - Ensure the Enable checkbox is checked. That sets or unsets the Error
  62. Reporting settings for you.
  63. 4. Configure Error reporting
  64. - Go to Administer -> Site configuration -> Error reporting
  65. - For 403 (access denied), enter the value:
  66. customerror/403
  67. - For 40 (not found), enter the value:
  68. customerror/404
  69. 5. Test your error pages.
  70. - Copy your present admin page url.
  71. - Try to go to a non-existent Drupal page on your site.
  72. You should see your custom error page for 404 (not found) page.
  73. - Log out from your site.
  74. - Paste the admin page url and try to go there.
  75. You should see your custom error page for 403 (access denied) page.
  76. Bugs/Features/Patches
  77. ---------------------
  78. If you want to report bugs, feature requests, or submit a patch, please do so
  79. at the project page on the Drupal web site.
  80. http://drupal.org/project/customerror
  81. Author
  82. ------
  83. Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
  84. If you use this module, find it useful, and want to send the author
  85. a thank you note, then use the Feedback/Contact page at the URL above.
  86. The author can also be contacted for paid customizations of this
  87. and other modules.