Simple model and front-end views
I have a simple model that I built called Buildings (buildings_model) and all the admin features work as expected. I'm trying to build out the front-end views for it, but having trouble wrapping my head around it. I'm probably just missing a piece of knowledge to connect everything together.
My models config looks like:
$config['modules']['buildings'] = array(
'module_name' => 'Buildings',
'module_uri' => 'buildings',
'instructions' => 'Manage available buildings.',
'permission' => 'building',
'sanitize_images' => false,
'js' => 'buildings/admin.js',
'css' => 'building_admin.css',
);
I created a building page in the admin area, but I am unsure how to format any data that (might) be passed to it. I tried creating a buildings controller and added the
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'buildings'));
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();
without any luck. Nothing was displayed. I then just loaded the view via $this->load->view('buildings',$data); but this loads the view without the template. I'm sure I could include a header/footer for each view, but I'd prefer to have this done automatically.
I also tried the controller extending Controller and CI_Controller, but when I tried $this->load->model('building_model'); I get an error.
In case it helps, the front-end is just going to be for displaying data - no forms or processing at this time.
Comments
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'buildings', 'render_mode' => 'cms'));
If you want the page to pull from the view, you can set the 'render_mode' => 'views'
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'buildings', 'render_mode' => 'views'));
If that still isn't loading what you wan, you may want to verify what layout is associated with that page (default is "main").
If you want the page to be created in the admin but also pull in model data from the buildings model, I'd maybe recommend creating a block file to hold that logic (either static or in the CMS) and then merge it in like so:
// if page is in CMS... {fuel_block('building_block')} // if static block in the views/_blocks folder <?=fuel_block('building_block')?>
Or you can enter in the logic in the page fields (e.g. "body" field) in the CMS using the Dwoo templating syntax:
http://www.getfuelcms.com/user_guide/parsing/parsing_examples
Let me know if any of those fix your issue.
Thanks!