1

Is it possible to have - instead of a dedicated 403/404 page - just a custom div inserted into the front page? 'Cause when I think of what I'd like to show up at 403404, I want everything that the front page has. So, whatever the front page looks like over time, I would just want it to adopt a 403/404 message div.

1

In D6's Error Reporting, if you set your 404 page to 'node', eg the standard front page, you should be able to do something like this in your hook_preprocess_page():

function YOURTHEME_OR_MODULE_preprocess_page(&$vars) {

  // all your other stuff

  if ($_GET['q']=='node' && !$vars['is_front']) {
    $vars['YOURTHEME_OR_MODULE_404_on_front']='<DIV>404 ON FRONT</DIV>';
  }
}

and then just do a:

<?php if (isset($YOURTHEME_OR_MODULE_404_on_front)): ?>
  <?php print $YOURTHEME_OR_MODULE_404_on_front; ?>
<?php endif; ?>

inside your page.tpl.php where you want the information telling your users about the 404.

The only reason I think the above silliness works is because drupal's 404 handler builds the 'node' page manually and displays it, but the theme layer sees what you really typed (eg, myhost.com/foo/bar/baz/bing) and doesn't think it's the front page and sets $is_front accordingly.

I'd assume all of the above would work for a 403 as well, but I haven't figured out a way to pass in which error actually happened, so, you'd have to have this "block" information pretty generic, eg "Oops. You are in a maze of twisty little passages, all alike..." :)

  • I like this method better, although I seem to be stuck at passing variables between preprocess and tpl, despite clearing caches thousand times. drupal_get_http_header('status') returns '403 Forbidden', '404 Not Found' (and probably other codes as well) – Artur May 14 '12 at 11:16
1

You can make this with the following configuration and using Rules module. 1. create a page with a custom path ex, "404" and set this page as 404 on configuration -> site information 2. create a rule, if the request page its "404" then 2.1 system page redirect 2.2 system show a message

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.