Help with fuel_modules.php file

edited November 2013 in News & Announcements
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

  • edited 4:28AM
    A few questions:
    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?
  • edited 4:28AM
    Hi Admin, thanks for replying.

    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
  • edited 4:28AM
    By body field, I meant the contents of what was in the field labeled body in the CMS when creating the page and not the "body" tag.

    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.
  • edited November 2013
    So if I'm understanding this correctly, my travel controller would be something like:

    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?
  • edited 4:28AM
    Yeah. The array('location' => 'my_page'...) should be substituted with your actual page and the $vars variable should have any additional variables that you need to pass to the page. The 'render_mode' => 'cms' is crucial for pulling the information from the CMS explicitly if their is a matching view file at a similar location. Does this work for you?
  • edited 4:28AM
    There must be more to this because what I'm doing isn't working. Complete controller code below.

    <?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.
  • edited 4:28AM
    And there is a view file or CMS page with a location value of "travel/cruises"?
  • edited 4:28AM
    Yes, travel is the controller, cruises is the view
  • edited 4:28AM
    But is there an actual page in the CMS created with a location value of "travel/cruises" (under the Pages module)? Alternatively, if you change the render_mode parameter from "cms" to "views", you could have a view file located at fuel/application/views/travel/cruises.php
Sign In or Register to comment.