How to load module's view from its controller with a layout?

edited June 2014 in Share
I've created a module at this location: fuel/modules/module-name/
The module-name directory contains these directories: views, models and controllers
I am trying to load a module view from a controller using this code:
array('location' => '/modules/module-name/views/myClass')
But I get this error:

Unable to load the requested class: myClass

I also tried this:
And got this error:

Unable to locate the file: modules/module-name/views/myClass.php

How can I load myClass.php file from controller? I need to render this view with the main layout (along with header and footer). How can I tell fuel to load this view using the main layout?


  • edited 3:40AM
    What version of FUEL are you using (you can echo the FUEL_VERSION constant to find out)? The reason I ask is because the syntax above is older.

    $vars = array(); $this->fuel->pages->render('mylocation', $vars, array('view_module' => 'my_module'));
  • edited June 2014
    I am using version 1.0.6 which should be the latest. Your approach does not raise any error, but I just get an empty page:
    $vars = array();
    echo FUEL_VERSION; // this is written to the output
    $this->fuel->pages->render('registeration', $vars, array('view_module' => 'registeration')); // nothing happens
    Here is the hierarchy of files in the module I intend to use:




    The content of "controllers/registeration.php":

    class Registeration extends CI_Controller
    public function add()
    $vars = array();
    echo FUEL_VERSION;
    $this->fuel->pages->render('registeration', $vars, array('view_module' => 'registeration'));
    The content of "views/registeration.php" is:

    <?php echo 'registeration';?>
    What am I doing wrong here?
  • edited 3:40AM
    Is there anything I am missing in my code?
  • edited 3:40AM
    What is the URI location relative to your web folder that is causing the problem? You may also want to add "render_mode" => "views" next to the "view_module" => "registeration".
Sign In or Register to comment.