Create new view with Fuel menus


I have recently started using Fuel CMS, and I would like to create a new view without a data model. Have checked the documentation, but cannot find how to do this.

I started a new project and after setup logged in, everything is working as expected.
Then created a new advanced module with the command:
php index.php fuel/generate/advanced reports
So, now I have a "Reports" entry in the left menu and a reports folder in the fuel/modules/ folder.

After this, I have created fuel/modules/reports/config files and fuel/modules/reports/views/report1.php
I created a html form in report1.php and I can click on the report1 entry in Reports, in the left menu, to view it, but there are no Fuel menus or header, just the form on a white background.

Could only find this old example of a view with menus working, but in my new project I am getting php errors instead of the left menu entries and my form is not fully visible, as it is under the left menu.

This is my report1.php file:
`<?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_header'); // set some render variables based on what is in the panels array $no_menu = (!$this->fuel->admin->has_panel('nav')) ? TRUE : FALSE; $no_titlebar = (!$this->fuel->admin->has_panel('titlebar')) ? TRUE : FALSE; $no_actions = (!$this->fuel->admin->has_panel('actions') OR empty($actions)) ? TRUE : FALSE; $no_notification = (!$this->fuel->admin->has_panel('notification')) ? TRUE : FALSE; ?>

fuel->admin->ui_cookie('leftnav_hide') === '1') ? ' class="nav_hide"' : ''; ?>>
<?php if ($this->fuel->admin->has_panel('top')) : ?>

<?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_top'); ?>
<?php endif; ?>
    <?php if ($this->fuel->admin->has_panel('nav')) : ?>
        <!-- LEFT MENU PANEL -->
        <?php $this->load->module_view(FUEL_FOLDER, '_blocks/nav'); ?>
    <?php endif; ?>

    <div id="fuel_main_panel<?=($no_menu) ? '_compact' : ''?>">
        <?php if ($this->fuel->admin->has_panel('titlebar')) : ?>
            <!-- BREADCRUMB/TITLE BAR PANEL -->
            <?php $this->load->module_view(REPORTS_FOLDER, '_blocks/titlebar_preactas')?>
        <?php endif; ?>

        <?php if ($this->fuel->admin->has_panel('actions') AND !empty($actions)) : ?>
            <!-- ACTION PANEL -->
            <div id="fuel_actions">
                <?php /* ?><?=$this->form->open('action="'.$form_action.'" method="post" id="form_actions" enctype="multipart/form-data"')?><?php */ ?>
                <?php if (!empty($actions)) : ?>
                <?php endif; ?>
                <?php /* ?><?=$this->form->close()?><?php */ ?>
        <?php endif; ?>

        <?php if ($this->fuel->admin->has_panel('notification')) : ?>
            <!-- NOTIFICATION PANEL -->
            <div id="fuel_notification" class="notification">
                <?php if (!empty($notifications)) : ?>
                <?php endif; ?>
                <?php if (!empty($pagination)): ?>
                <div id="pagination"><?=$pagination?></div>
                <?php endif; ?>
        <?php endif; ?>

        $main_content_class = '';
        if ($no_actions AND $no_notification) : $main_content_class = 'noactions_nonotification';
        elseif ($no_actions AND $no_titlebar) : $main_content_class = 'noactions_notitlebar';
        elseif ($no_titlebar) : $main_content_class = 'notitlebar';
        elseif ($no_actions) : $main_content_class = 'noactions';

        <div id="fuel_main_content<?=($no_menu) ? '_compact' : ''?>"<?=(!empty($main_content_class)) ? ' class="'.$main_content_class.'"' : ''?>>
            <!-- BODY -->
            <?php $this->load->module_view(REPORTS_FOLDER, 'preactas_content');  ?>

            <?=$this->form->hidden('fuel_inline', (int)$this->fuel->admin->is_inline())?>

<div id="fuel_modal" class="jqmWindow"></div>

<div id="fuel_main_content_inner">
    <div id="fuel_main_content_line" style='margin-bottom: 20px;'>

    <div id="fuel_main_content_line">
        <form enctype="multipart/form-data">
            My form


And this is the text I get instead of the left menu entries:
`A PHP Error was encountered
Severity: Warning

Message: Undefined variable $nav_selected

Filename: _blocks/nav.php

Line Number: 59


File: /var/www/html/autoPIR/fuel/modules/fuel/views/_blocks/nav.php
Line: 59
Function: _error_handler`

I know a nav_selected option can be added to MY_fuel_modules.php so added following line to it, but produces other errors, as there is no model or tables related:
$config['modules']['reports'] = array();

Is it possible to get this kind of view working?
An example would be very useful.

Thanks for your help!


  • Try the following instead (feel free to change the value from 'reports' to what you need to appear selected in the admin when in the module):

    $config['modules']['reports'] = array(
        //... other configuration
        'nav_selected' => 'reports',
  • edited July 2023

    Thanks for your answer!

    I already tried that, I am getting this when setup that config:
    `An uncaught Exception was encountered
    Type: RuntimeException

    Message: Unable to locate the model you have specified: Reports_model

    Filename: /fuel/codeigniter/core/Loader.php

    Line Number: 349`

    If I create the Reports_model then I get an error about the table reports that does not exists, and when the table is created this:
    `A PHP Error was encountered
    Severity: Warning

    Message: Undefined array key 1

    Filename: libraries/Fuel_modules.php

    Line Number: 774`

    Anyways Fuel interface is not loaded correctly and my view is under the left menu, so cannot be used properly.


  • Actually, you created an "Advanced Module". Advanced modules are a way to sort of "name-space" your code and make it modular by not interfering as much with your fuel/application directory. They can contain "Simple Modules" (e.g. like the Blog and Forms module examples listed below):

    In your case, there should be a fuel/modules/reports/controllers/Reports.php file. Are you able to determine if that is the controller serving up the page? If so, you may need to pass it the 'nav_selected' variable upon rendering in the controller.

    It's a little unclear what you are trying to do with the code above. If you are wanting to create a simple form that houses report information, that sounds like you may want to create a "Simple Module".

    Regarding examples, I'd recommend looking at some of the other Advanced modules:



  • I wanted a module/controller/view/form/whatever inside the CMS but without a model.
    As it seems not possible (pages are too simple), I will think another way to do it.

    Thanks for your help.

  • You can totally do it but you'll need to think of traditional CI controller view and routing. You may need to add your route to your fuel/modules/reports/reports_routes.php file and to get rid of the $nav_selected error, you'll need to just make sure the variable is passed to the view.

Sign In or Register to comment.