How to display a simple html page in fuel admin?

I want to display a changelog in the fuel backend so I created a file here:

fuel\modules\fuel\views\changelog.php

<div id="fuel_main_content_inner">

    <?php echo file_get_contents(APPPATH.'/changelog.md') ?>

</div>

But calling /fuel/changelog just gives me a 404

How can a make this page available and in the best case create a link in the Tools menu.

Or do I have to create an advanced Modul for that?

Thanks! m.

Comments

  • It would probably be best to create an advanced module for that instead of updating the core fuel/modules/fuel files.

    Alternatively, you could create a controller and route in your main application/controllers directory and application/config/routes.php respectively. The controller can inherit from the Fuel_base_controller.php (which will lock the public out and require you to be logged in) and have a method that renders that page.

    To add the menu item, you can add the item to the fuel/application/config/MY_fuel.php file under the $nav['tools'] array where the key is the route path and the value is the label of the menu item.

  • I think the Advanced Module is the way to go, so I just extended the user_guide Module for that. Perfect place.

    Thanks for pointing out the alternative way. Good to know.

  • Just for the record, in case someone is searching for that:

    I replaced the dashboard with the other method you pointed out.

    fuel/application/config/routes.php

    $route['default_controller'] = 'fuel/page_router';
    $route['404_override'] = 'fuel/page_router';
    $route['translate_uri_dashes'] = FALSE;
    
    /*  
    | Uncomment this line if you want to use the automatically generated sitemap based on your navigation.
    | To modify the sitemap.xml, go to the views/sitemap_xml.php file.
    */ 
    //$route['sitemap.xml'] = 'sitemap_xml';
    
    include(MODULES_PATH.'/fuel/config/fuel_routes.php');
    
    // overwrite dashboard to find new /application/controllers/Dashboard.php
    $route['fuel/dashboard'] = 'dashboard';
    $route['fuel/dashboard/ajax'] = 'dashboard/ajax';
    

    /application/controllers/Dashboard.php (with my custom code for fuel dashboard modules and whatever else should appear on the dashboard

    <?php
    require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php');
    
    class Dashboard extends Fuel_base_controller {
    
        public function __construct()
        {
            parent::__construct();
            $this->js_controller = 'fuel.controller.DashboardController';
        }
    
        public function index()
        {
            if (is_ajax())
            {
                $this->ajax();
            }
            else
            {
                $this->fuel->load_model('fuel_users');
                $auth_user = $this->fuel->auth->user_data();
                $user = $this->fuel_users_model->find_by_key($auth_user['id'], 'array');
                $vars['change_pwd'] = ($user['password'] == $this->fuel_users_model->salted_password_hash($this->config->item('default_pwd', 'fuel'), $user['salt']));
    
                $dashboards = $this->fuel->admin->dashboards();
    
                $vars['dashboards'] = $dashboards;
                $crumbs = array('' => 'Dashboard');
                $this->fuel->admin->set_titlebar($crumbs, 'ico_dashboard');
                // my own templates
                $this->fuel->admin->render('_admin/dashboard', $vars, Fuel_admin::DISPLAY_NO_ACTION);
            }
        }
    
        /* need to be outside of index so when you click back button it will not show the ajax */
        public function ajax()
        {
            if (is_ajax())
            {
                $this->load->module_model(FUEL_FOLDER, 'fuel_logs_model');
                $vars['latest_activity'] = $this->fuel_logs_model->latest_activity(10);
    
                // my own templates
                $this->load->module_view('app', '_admin/dashboard_ajax', $vars);
            }
        }
    }
    

    and my custom dashboard views/templates

    application/views/_admin/dashboard_ajax.php (renders fuel specific dashboard items like RSS Feed, Last Modified etc. and application/views/_admin/dashboard.php (the page itself) are copied from fuel/modules/fuel/views/* and modified with different CSS classes or whatever else I wanted to change.

Sign In or Register to comment.