I'm new to fuel, but not to CodeIgniter. I'm starting on a project using Fuel for the first time. I created a page called "home" via the CMS using a custom layout I made based on the default layout. That all works fine. In my layout, I have some spaces where I want to fill with some generated content which I plan to do with fuel variables. I created a controller called home.php, the code for this is as follows:
class Home extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$vars = array();
$vars['top_content_block'] = "This is top content";
// use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing
$page_init = array('location' => 'home');
$this->load->module_library( FUEL_FOLDER, 'fuel_page', $page_init );
$this->fuel_page->add_variables( $vars );
$this->fuel_page->render();
}
}
When going to the sites main page just using the domain name, the regular home page still comes up. But when trying to go to /home, I just get a blank page. I've put some debugging in there and it's definitely getting to my controller.
My $config['fuel_mode'] variable is set to "auto".
I guess some of the questions I have are:
1) If I create a page via the CMS, can I create a controller for it and still have fuel use the layouts and content stored in the db? Is that the purpose of the last three lines in the controller?
2) My goal is to create most pages with some editable content and some programmed content. The owner of the site is not XHTML/CSS savvy and I want him to be able to edit some content, so my plan was to create different layouts for the different types of page designs, then use controllers to add the content I need to add, but have fuel render the pages and pull the edited content from the db and use the layouts. Should what I'm thinking be doable and anything special I need to know?
Thanks,
Bruce
Comments
However, when going to the root of the site without the "/home", it doesn't seem to be using my controller even though the default home page is set to "home". Is there a way to fix that? I'm sure I can always redirect root requests to the "/home" url via mod_rewrite, but is there a better way using fuel itself?
Bruce
Bruce
function index()
{
$data = array();
$data['view'] = 'home/index';
$page_init = array('location' => 'home');
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
$this->fuel_page->add_variables($data);
$this->fuel_page->render();
}
Home page created in CMS with Controller works!