Custom navigation for 404 page

edited May 2015 in Modules
I am using some custom templates. It seems that for 404 pages(if I write something wrong in url - a function name that doesn't exist in the controller) I get errors like:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: menu

Filename: _blocks/navigation.php

Line Number: 17
How should I send $menu variable for 404 pages? If I comment the line than I will get further errors like:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Page_router::$auth

Filename: _blocks/navigation.php

Line Number: 38

Fatal error: Call to a member function is_logged_in() on a non-object in ...\fuel\application\views\_blocks\navigation.php on line 38

The code from navigation.php which gives the last error is :

<?php if ($this->auth->is_logged_in()) { ?> <?php } ?>

Comments

  • edited 8:10PM
    The CI 404 error page doesn't go through a normal controller which is why you see in the default fuel/application/errors/error_404.php it includes and requires things for it to render.

    If you create a view file of "404_error" or a page in the CMS of 404_error it will be used instead of the default CI 404 error page if the function redirect_404() is called instead of show_404(), which is done by default with FUEL.
  • edited 8:10PM
    What I have done and no it seems fine:
    added in fuel/application/views/_variables/global.php
    $vars['CI'] = &get_instance();
    $CI->load->library('navigation');
    $vars['menu'] = $CI->navigation->menu_items();
    $vars['submenu'] = $CI->navigation->submenu_items();
Sign In or Register to comment.