Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Empty page is rendered when creating a controller.

edited May 2011 in Installation
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

  • edited 12:26AM
    The body variable gets set by FUEL based on the location specified (e.g. contact). If you create a view file located at fuel/application/views/contact.php, it should work.
  • edited 12:26AM
    Indeed that worked ...
    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 ??
  • edited 12:26AM
    You can control the layout via the variables just like you have there. However, the body of the page is controlled by the URI location / view location relationship, if you are indeed using FUEL's "opt-in controller" method (which it looks like you are).

    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?
  • edited 12:26AM
    Yes I really understand this point of working with Fuel but...
    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 ....
Sign In or Register to comment.