It looks like you're new here. If you want to get involved, click one of these buttons!
<?php
class Test extends CI_Controller {
public $view_location = 'test';
function __construct()
{
parent::__construct();
}
function contact()
{
//echo "test"; -> works when uncommented
// set your variables
$vars = array(
'page_title' => 'Contact : My Website',
'data' => 'if all goes well this should be visible'
);
//... form code goes here
// load the fuel_page library class and pass it the view file you want to load
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'test/contact'));
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();
}
}
<?php print $data; ?>
<p>more text</p>
Comments
'render_mode'=>'cms'
to your module_library array:
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'test/contact', 'render_mode' => 'cms'))
Does anyone have a working example of an easy-to-understand advanced module? The blog is way too advanced and furthermore makes no use of module_library() in the way we need to to load a view.
When I remove the membership.php file from this location I get a blank page.
<?php class Membership extends CI_Controller { public $view_location = 'membership'; // although here, view is still loaded from main application/views function __construct() { parent::__construct(); $this->config->load('membership', 'membership'); } function index() { // set your variables $vars = array('page_title' => 'Membership'); // load the fuel_page library class and pass it the view file you want to load $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'membership'/*, 'views_path' => 'membership'*/)); $this->fuel_page->add_variables($vars); $this->fuel_page->render(); //$this->load->view('membership', $vars); // loads view from correct module folder } }
When I add 'views_path' => 'membership' I get a blank page.
Adding 'render_mode'=>'cms' (or 'views') does not change anything.
So in fact my only issue to solve is to get the correct views path loaded. I hope.
If you are simply just wanting to load that view you can use:
$this->load->module_view('membership', 'my_membership_view', $vars);
If you have content on that page that you want to include inline editing with, you can do something like the following (grabbed from Blog_base_controller):
$output = $this->load->module_view('membership', 'my_membership_view', $vars, TRUE); $this->load->module_library(FUEL_FOLDER, 'fuel_page'); $this->fuel_page->initialize(); $output = $this->fuel_page->fuelify($output); $this->output->set_output($output);
I should have included what I want to accomplish. I'd like to use the layout files from MY_fuel_modules and have my module view inserted into it (in stead of loading the one in fuel/application/views). Should I call them with the $vars array (and how?) or should I create a separate _layout folder for my module?
I'd like to use the MX way of working with modules per site section so that in case I need to move them to another project I have to copy just one folder.
I'm loving this CMS btw, just here and there it's fairly different from anything I've done before in CI.
I'm getting results!
In that method, it grabs any variables associated with the current uri path with:
$_vars = $this->fuel_pagevars->retrieve(uri_path());
It then loads the content of the page into a "body" variable, which then gets loaded into the layout. Passing the output to the "fuelify()" method at the end will convert any inline editing code
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'membership/register'));
How can I get the location to load my module view in stead of the view in fuel/application/views? Sorry for all the trouble.
EDIT:
made some progress:
$vars['body'] = $this->load->module_view(MEMBERSHIP_FOLDER, 'themes/default/test', $vars, TRUE); $view = $this->load->view('_layouts/main', $vars); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $view); $this->fuel_page->add_variables($vars); $this->fuel_page->render();
But now I get the FUEL_MARKER placeholders where global variables should be. I feel like I'm close and want that sigar . I'm merging the $_vars with my existing $vars array as you suggest but must be doing something wrong.
the global vars are loaded though so the markers being there is not a very big problem for me.
Is there a way to make fuel_var() available? I tried loading the fuel_helper in my membership controller but to no avail.
Thanks
require_once(FUEL_PATH.'helpers/fuel_helper.php'); could it work? trying in different locations.
$vars['body'] = $this->load->module_view(MEMBERSHIP_FOLDER, 'themes/default/test', $vars, TRUE); $output = $this->load->view('_layouts/main', $vars, TRUE); $this->load->module_library(FUEL_FOLDER, 'fuel_page'); $this->fuel_page->initialize(); $output = $this->fuel_page->fuelify($output);
As soon as I put
$output = $this->load->view('_layouts/main', $vars, TRUE);
to TRUE it returns a blank page.Unless I add
print $output;
at the bottom. Then everything works as it should. Markers are gone. Return doesn't work, same blank page.Also, whether I add
$this->load->module_library(FUEL_FOLDER, 'fuel_page'); $this->fuel_page->initialize();
or not, no difference.Is there a time when markers should be displayed? Whether I log in or not, don't see them.
Edit: using
$this->output->set_output($output);
Works and is much better then using print, I think this is solved? In the meantime I got to know the code a whole lot better!Thanks for your persisent assitance!!