make CustomError use a custom page.tpl.php?

ceejayoz - July 17, 2007 - 13:06
Project:CustomError
Version:5.x-1.1
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Is it possible to make CustomError use a custom page template, ala page-customerror.tpl.php?

#1

pht3k - October 8, 2007 - 18:21

would be very nice :)
was coming here in the issues section with he hope of finding such an info...

pht3k

#2

kbahey - October 9, 2007 - 02:30

I have not tired, but it should work in principle.

In the template.php file of your theme, add the following function:

function phptemplate_customerror($error_code = 404, $content = NULL) {
return _phptemplate_callback('customerror', array('error_code' => $error_code, 'content' => $content));
}

Then create a customerror.tpl.php and put in it what you want.

Not sure if it will do what you want, but worth a try.

#3

pht3k - October 9, 2007 - 02:58

hi,

well i was asking because i wanted back the columns drupal 5.1 removed from the error pages, and i just found here how to do this:
http://drupal.org/node/129762

but thanks for your reply; it is some info i was seeking for an other issue...
pht3k

#4

mairav - September 6, 2009 - 06:17

What @kbahey mentioned in #2 in Drupal 6 would be:

function phptemplate_customerror($error_code = 404, $content = NULL) {
return theme_render_template('sites/all/themes/afd/customerror.tpl.php', array('error_code' => $error_code, 'content' => $content));
}

#5

delizyd - September 26, 2009 - 01:20

Hi,
I have just tried your function but doesn't work. What's wrong, any idea?

K.B.

#6

mairav - September 27, 2009 - 19:33

In

function phptemplate_customerror($error_code = 404, $content = NULL) {
return theme_render_template('sites/all/themes/afd/customerror.tpl.php', array('error_code' => $error_code, 'content' => $content));
}

You have to change the word "afd", for the name of your theme, and then place in your theme folder the file customerror.tpl.php with the template in the way you want you custom error to appear.

#7

kbahey - September 27, 2009 - 22:37

Better than hard coding the theme path, you can do:

<?php
function phptemplate_customerror($error_code = 404, $content = NULL) {
return
theme_render_template(base_path() . path_to_theme() . '/customerror.tpl.php', array('error_code' => $error_code, 'content' => $content));
}
?>

The code will be more portable this way.

#8

mairav - September 27, 2009 - 22:48

@kbahey Thanks! that did the job!

#9

delizyd - September 28, 2009 - 14:10

Even I create empty customerror.tpl.php file or leave only print $content line in the file all default page areas (header, content, footer) are still loaded.
So, I guess that this code doesn't help me to change the way 404 page will be displayed. Am I right?

Thanks for all answers.

 
 

Drupal is a registered trademark of Dries Buytaert.