Advanced Controller views v 1.0
So, here we go again
What I have is an advanced module.
Works awesome through the CMS.
Now, I need to implement the front-end portion of it. Right now all I want to do is have the module's view file output some form information, but to start I just want it to output $vars['body'] = 'test'; to the view file in /modules/membership/views/membership.php
I can do that, no problem.
So, my issue comes with implementing the sites view files: /application/views/_layouts/main.php which includes /application/views/_blocks/header.php and footer.php
I can do that too.
What happens when I do that though is my Site Variables from the CMS don't transfer through, and neither do css($css) or js($js).
Here's my controller for my membership module controller:
<?php
class Membership extends CI_Controller {
public $view_location = 'membership';
function __construct()
{
parent::__construct();
}
function index() //
{
$vars['body'] = 'test';
//$this->fuel->page->initialize(array('layout' => 'main'));
//$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'membership'));
//$this->fuel->page->add_variables($vars);
$this->load->view('membership', $vars);
//$this->fuel->pages->render('membership',$vars);
}
}
As you can see I've tried a few different things. Also, is using CI_Controller correct?
So that does ALMOST what I want, eventually I'll have portions of this module with various forms outputting to the view file which will be inline with the whole site.
Here's the view file I'm using in /modules/membership/views/membership.php:
<?php
$this->load->module_view('app', '_blocks/header.php');
if (isset($form)) { // display any form content
echo $form;
}
echo $body; // display any $body content
echo 'membership';
$this->load->module_view('app', '_blocks/footer.php');
Seems pretty straightforward doesn't it?
Comments
... $vars['body'] = 'test'; $params['view_module'] = 'membership'; $this->fuel->pages->render('membership',$vars, $params);
$this->fuel->pages->render('membership',$vars);
or the following error when I include $params (as it says in the docs):
Fatal error: Call to a member function call_hook() on a non-object in /home/eng51dev/public_html/restautrade/fuel/modules/fuel/libraries/Fuel_pages.php on line 758
The docs:
$this->fuel->pages->render('$location', [$vars=array()], [$params=array()], ['$return'=FALSE])
However, for some reason the $css and $js variables aren't defined still even with that code?
Though, I have full access to the Site Variables now which is awesome.
What about including js files in the module js folder?
I tried adding $vars['js'] = array('javascriptfile') but it tried adding it from the application folder.