Need help with Layouts in Advanced Module

edited April 2011 in Modules
Hello all, I'm completely new to Fuel, but fairly experienced with Codeigniter. I'm having trouble understanding Advanced modules, and hope someone can help, or at least point me in the right direction. My eventual goal is to build a protected section for Sales Reps to log in and view various information from the front end. I've got Simple modules down pretty well, as I have created some and integrated them with the admin section.
Now I'm trying to build an advanced module, and am getting nowhere fast. I'm just trying to build a very simple advanced module to learn on for now. I have followed the User Guide and created a folder in "modules" called "sales_reps". Inside that folder I have my config folder with "sales_reps.php", "sales_reps_constants.php" and "sales_reps_routes.php", I also have a "views" folder and a "controllers" folder. Inside the "controllers" folder, I have "sales_reps.php" which extends the Fuel_base_controller and has an index() method. The index method just loads a view that says Hello World. What I'd like to do is to use the layouts and blocks that I have in "application/views" to display the $body which is defined in "modules/sales_reps/views/sales_reps.php".
If I just load the view using

$this->load->view('sales_reps');

then I can see Hello World, but it doesn't use any layout. I've tried to use

fuel_set_var('layout', 'c_main');

but that has no effect. I've also tried copying my layouts into the modules views folder; still no luck.
Finally, I've tried using the following:

$page_init = array('location' => 'sales_reps');
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();

Still no luck. Except now I get all sorts of errors.

At this point, I feel like an idiot. Can anyone point me in the right direction?
Thanks in Advance.

Comments

  • edited 3:01AM
    Try changing your $page_init to this:
    $page_init = array('location' => 'sales_rep', 'views_path' => 'sales_rep');
    The 'views_path' value will point fuel_page to your 'sales_rep' modules view folder. Also, the location value is used to grab the view file and in this case it will look for the file fuel/modules/sales_rep/views/sales_rep. Alternatively, you can pass a 'view' variable to the page in the $vars array. Does that help?
  • edited 3:01AM
    That did the trick. Thanks for the help! I have to say that I'm very impressed with Fuel. It's going to be my new Go To framework.
  • edited 3:01AM
    Thanks!... and glad it worked for you.
Sign In or Register to comment.