Empty page is rendered when creating a controller.
It must be somthing I looked over in the documentation because the use seams to be very obvious, nevertheless I recieve an empty page when rendereing a page from my controller.
I have created a controller in fuel/application/controllers/contact.php
<?php
class Contact extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index(){
$page_init = array('location' => 'contact', 'render_mode' => 'cms');
$vars = array();
$vars['body'] = "yes the body is here";
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();
}
}
Im just using the main view as an example and want to display some text in the body part
main.php
<?php $this->load->view('_blocks/header')?>
<?php echo fuel_var('body', ''); ?>
<?php $this->load->view('_blocks/footer')?>
The page however is empty ...
Any thoughts to look for ???
Comments
I was under the impression that you could control the layout via the variables. If you put $vars['layout'] = 'my_layout'; in the fuel/application/view/_variables/contact.php
Anyway I was looking to have one lauyout for the entire site and creating a view file per controller (20 controllers ), perhapse there is a better sollution then just copy it to the appropriate name ??
When you say 20 controllers, do you mean 20 view files? Most of the time with FUEL, you just build controllers only if you need to do some more complicated processing (like a contact form). Otherwise, you can just create view files and map variables to them via the _variables files without the need to create a controller. Does that answer your question?
I come from a CI website that has a lot of logic in controllers and now we want to add some text/images around...
So just changing the 20 controllers with some line of code is easy in labor time but it seams not the best solution here.
Anyway I will use the best of both worlds :-)
Thanks for the info, I surely will talk to you later ....