[eluser]@robertotra[/eluser]
[quote author="luismartin" date="1328379633"]... I'm trying to figure it out... how do you get the necessary data (main menu, footer, etc) to display it in the modified default error_404.php page? [/quote]
Of course there is always more than a way to do the same thing, but this is what I suggest: inside the file where you prepare the 404 page content (it maybe a controller or a custom library or a helper, it depends by your application structure), put the views inside one or more global variable, as example:
Code:
// this is just an example on how you can organize page content
$data['one'] = 'your 1st data for the view';
$data['two'] = 'your 2nd data for the view';
$data['three'] = 'your 3rd data for the view';
// and so on...
// put your custom view inside a global variable
// use instanceof $CI->load if inside a helper or a custom library
$GLOBALS['404page'] = $this->load->view('your404view', $data, true);
At this point, the global variable will be available inside the 404 page, that might be:
Code:
<?php
// if you put the whole page inside a single variable, you just need
echo $GLOBALS['404page'];
If you use in the 404 page the same heading and footer than the normal pages, split the page content into more views and put the headings preparation outside the main controller, inside a helper or a class that can be loaded by both controllers (main and error). Then the final 404 page might be something like that:
Code:
<?php
echo <<< STOP
{$GLOBALS['heading']}
<p class='warnBox'>
<h2 class='warnTop'>{$GLOBALS['title']}</h2>
<h3 class='warnMex'>{$GLOBALS['message']}</h3>
</p>
{$GLOBALS['footer']}
STOP;
I suggest also to put before the echo statement some basic check to avoid that a variable is empty, setting some default content if anything went wrong (so you can check that the process was ok)
Roberto