Addding 3rd Party Application as a Dashboard Item

edited October 2012 in Modules
I am evaluating fuel cms to develop an ecommerce application. For this purpose, I would like to integrate Flexi cart to Fuel CMS. I created an Advance module and added all those files that comes with the Flexi Cart inside the newly created folder. I am following the documentation listed here http://www.getfuelcms.com/user_guide/modules/advanced.

After doing the configuration stuff, I am getting a screen like below when I try to access it from the dashboard with the following url: http://localhost/testcommerce/index.php/fuel/flexi_cart/admin_library/items
******************************************************************
A PHP Error was encountered
Severity: Notice

Message: Undefined property: Module::$model_name

Filename: controllers/module.php

Line Number: 79

An Error Was Encountered
Unable to locate the file: .php
********************************************************************
Please help.

Comments

  • edited 8:36AM
    That error is because of the route I think and it's defaulting to the module.php controller which in this case we don't want since Flexi cart has it's own controllers.

    I did a quick test to see if I can get this installed and got pretty far along with the following steps:

    1. Downloaded the FUEL 1.0 beta (although this will probably be the same steps as .93)
    https://github.com/daylightstudio/FUEL-CMS/tree/1.0
    2. Created a fuel/modules/flexicart folder and put in all the libraries, controllers, models, config files including
    3. Added a flexicart_routes.php with the following (which you may need to adjust):
    $route[FUEL_ROUTE.'flexicart'] = 'flexicart'; $route[FUEL_ROUTE.'flexicart/(:any)'] = 'flexicart/$1';
    4. Created a flexicart_constants.php file:
    define('FLEXICART_VERSION', '1.0'); define('FLEXICART_FOLDER', 'flexicart'); define('FLEXICART_PATH', MODULES_PATH.FLEXICART_FOLDER.'/');
    5. Added a flexicart.php config file (note it's not flexi_cart.php) with the following:
    $config['nav']['modules']['flexicart/admin_library'] = 'Flexicart';
    6. Needed to include the Flexi_cart_lite class in the libraries/Flexi_cart_admin.php because the load_class('Flexi_cart_lite', 'libraries', FALSE); didn't work:
    //load_class('Flexi_cart_lite', 'libraries', FALSE); require_once(FLEXICART_PATH.'libraries/Flexi_cart_lite.php');
    http://localhost/flexicart/fuel/flexicart/admin_library/
    7. Needed to change the following in the constructor of the admin_library controller:
    $this->load->vars('base_url', 'http://localhost/flexicart/fuel/flexicart/'); $this->load->vars('includes_dir', 'http://localhost/flexicart/includes/');

    This got me to the point where I could see the admin. I hope that helps.
  • edited October 2012
    Thanks for the help. I have managed to get it working.
  • edited October 2012
    The integrated Flexi cart admin goes outside the frame. I want to display within the fuel cms admin screen on the right pane. I tried to render it this way.
    $this->fuel->admin->render('demo/admin_examples/dashboard_view', $vars,Fuel_admin::DISPLAY_NO_ACTION);

    Now it comes in the right pane, but the left pane shows an error:

    A PHP Error was encountered
    Severity: Warning
    Message: Invalid argument supplied for foreach()
    Filename: core/Loader.php(317) : eval()'d code
    Line Number: 18
    [edit]
    Later I found that it is due to the fact that I have not extended Fuel_base_controller in my admin_library controller. After I did that it's displaying correctly.
  • edited 8:36AM
    Hi, I thought I'd try and incorporate Flexicart into an advanced module for v1.0 of Fuel, but I've run into a "You are missing the module flexicart." error (generated in the module controller).

    I followed the 7 steps admin outlined above, and sure enough, got the Flexicart demo library admin to show - I could even insert data via its forms.

    But I want to retain the Fuel admin look and feel, so I started to think about how that could be done. For each admin link there needed to be a model, so starting with something simple like the "currency" table, I put a basic currency_model together (shame it's singular!). That didn't achieve anything until I created a "flexicart_fuel_modules" config file, and again, made the basic array entry for the model. It was after that point I got the "missing module" error.

    If I'm reading the module controller correctly, the error lies (line 49) with there being nothing returned by

    $this->fuel->modules->get($this->module, FALSE);

    where $this->module = 'currency' .

    The entry in flexicart_fuel_modules is:
    $config['modules']['currency'] = array( 'module_name' => 'Currency', 'module_uri' => 'flexicart/currency', 'model_name' => 'currency_model', 'model_location' => 'flexicart', 'archivable' => TRUE, 'nav_selected' => 'flexicart/currency', );

    So - am I really missing the module flexicart, or is there something wrong with the currency model (below)

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); // we use this class to be compatible with admin section(s) class Currency_model extends Base_module_model { function __construct() { // Call the Model constructor parent::__construct('currency'); $this->load->database(); } public $required = array('curr_name','curr_symbol'); // following function sets columns for admin display function list_items($limit = NULL, $offset = NULL, $col = 'curr_name', $order = 'asc') { $this->db->select("curr_id,curr_name,curr_symbol,curr_status", FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; } function form_fields($values = array()) { $fields = parent::form_fields($values); return $fields; } }
  • edited March 2013
    Update - the "missing module" message was being set by this evaluating true in module.php (line 47):

    empty($this->module_obj->name)

    If I substitute $this->module_obj->module_name and pre-assign it to a variable e.g.
    $is_this_empty = $this->module_obj->module_name; if (empty($is_this_empty)) { show_error(lang('error_missing_module', fuel_uri_segment(1))); }

    or test for empty($this->module_obj)

    then the expected admin page is shown, as the variable = 'Currency'.
  • edited 8:36AM
    Does it work if you change it from:
    empty($this->module_obj->name)
    To
    empty($this->module_obj->name())
    Note that it should be a method.
  • edited 8:36AM
    No - I get the error "Can't use method return value in write context".

    Hence assigning the method return to a variable in my earlier comment ie:

    ... $mod_name = $this->module_obj->name(); if (empty($mod_name)) ...

    which does work.
Sign In or Register to comment.