Help with fuel_modules.php file
Hi Fuel Forum, could use a little help here. So I've been on a project where I'm essentially porting a Codeignitor website into Fuel CMS. I've managed to get my controllers working and have imported view files into the CMS with everything intact. I thought I was done with this project, but it seems that I can't update a page through the CMS. In the importing process, I followed the instructions on
http://getfuelcms.com/blog/id/6 in the Importing Pages section. In that section is
"The import layout variable of body can be changed by modifying the js_controller_params import_view_key parameter in the fuel/modules/fuel/config/fuel_modules.php file." I don't know what to change this to unfortunately. Can anyone help? Much appreciated.
I guess it would help if I outlined what I did as well.
1. Upload codeignitor view files into directory where fuel view files reside. /fuel/application/views
2. Create page matching the URI of view file in /fuel/application/views.
3. Saved the page and clicked on "Yes" to the import dialog box that appears.
4. Confirmed that the view file was actually imported
5. Edited the page in the CMS and saved.
6. Changes to the view file fail to appear on the website :-(
Comments
1. In your fuel/application/config/MY_fuel.php file is the fuel_mode set to "auto"?
$config['fuel_mode'] = 'auto';
2. Do you have a "body" field in your layout and when imported, did the view contents display in that field?
3. If you click the view button, does your page appear?
Ok fuel mode is set to auto in MY_Fuel.php.
By Body field, I assume you mean code like this: ">
When I click the view button, I see a lot of the code that was imported into Fuel. However it doesn't take into account the use of a controller.
This url makes the one of the pages appear as it should. fuel is a subdirectory, travel is a controller. The number prefixing travsearch.com is actually a database value which determines the a lot of the content displayed. http://20023474.travsearch.com/fuel/travel/aboutus
This url without the controller reference displays code inside the editor. http://20023474.travsearch.com/fuel/aboutus
When creating a page in the CMS, and clicking view, it will use the fuel/modules/fuel/controllers/page_router.php controller if no controller matching the URI path is specified. If you have a controller setup and you want to render the contents of a page in a controller, in FUEL 0.93 you'll have to do something like the following in your controller method:
$vars = array(); // an array of extra variables $page_init = array('location' => 'my_page', 'render_mode' => 'cms'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render();
The "render" method will apply any variables set when creating the page in the CMS (e.g. page_title, meta_description, etc). It will also apply any variables set in your _variables folder that apply to that particular page. If you have additional variables you want to pass to the page, you can use the add_variables method as displayed above.
class Travel extends CI_Controller {
function __construct() {
parent::__construct();
}
$vars = array(); // an array of extra variables
$page_init = array('location' => 'my_page', 'render_mode' => 'cms');
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
$this->fuel_page->add_variables($vars);
// Rest of the controller code goes here
// It is an exhaustive amount of code
$this->fuel_page->render();
}
I know I don't have a function for pages here because I think I can pass all this information into any page through the controller. Is that right? I did follow the tutorial on http://adventuresincms.blogspot.com/2012/05/make-cms-content-appear-in-controller.html and did manage to come up with the results on this page, http://20023474.travsearch.com/fuel/home Unfortunately the CMS content didn't pass into the view through the controller. I know what I'm trying to do can be done, but maybe I'm going about this wrong?
<?php
class Travel extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->load->helper(array('form', 'url',));
$this->load->model(array('datamodel'));
$host = $_SERVER['HTTP_HOST'];
$agent_pin = explode('.',$host);
$agent_pin = $agent_pin[0];
$agent['agent'] = $this->datamodel->getRecords('khm_affiliate','',array('agent_pin'=>$agent_pin,'is_active'=>1),'',true);
if($agent['agent'])
{
$deal_detail = $this->datamodel->getRecords('khm_deal');
foreach($deal_detail as $deal_detail_row)
{
$agent['deal_detail'][$deal_detail_row['khm_deal_id']] = $deal_detail_row;
}
$destination_detail = $this->datamodel->getRecords('khm_destination');
foreach($destination_detail as $destination_detail_row)
{
$agent['destination_detail'][$destination_detail_row['khm_destination_id']] = $destination_detail_row;
}
$this->session->set_userdata('agent_email',$agent['agent']['email']);
$this->load->view('includes/header',$agent);
} else {
redirect('err');
}
}
function cruises() {
$vars = array(); // an array of extra variables
$page_init = array('location' => 'travel/cruises', 'render_mode' => 'cms');
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
$this->fuel_page->add_variables($vars);
$this->fuel_page->render();
}
}
/* End of file travel.php */
/* Location: ./application/controllers/travel.php */
?>
Putting the code in the cruises function directly in the __construct function didn't get me anywhere either. Really at loss here.