CI newbie - how to build my application with Fuel

pscpsc
edited December 2010 in Bug Reports
I'm a newbie to CI so I'm playing catch up here.

I want to use MVC to build some simple database related features. Nothing too complex.

What is the best way to go about this within the Fuel framework? Can I build my own model, view, and controller extending the code igniter classes, or must I build a module under Fuel to make this work?

I want to get experience with Code Igniter so I would prefer to build my application by extending the code igniter classes, and using their documentation before I get into creating a module for Fuel - is this possible??

I do want to utilize Fuel's layout and blocks, while running the functionality through Code Igniter.

Comments

  • edited 1:31AM
    What I would recommend is download the latest version of FUEL off of GitHub and use that as your CodeIgniter instance to play around with. You can build your own models, views and controllers like normal, you'll just have the extra functionality that comes with FUEL like the use of the layouts and blocks. To create a module, your models will need to extend the Base_module_model.php. Base_module_model extends MY_Model which has a bunch of extra functionality you can use with your models if you are simply extending database tables.
    http://www.getfuelcms.com/user_guide/libraries/my_model
  • pscpsc
    edited 1:31AM
    I got an error when trying to extend Controller - is there a Base_controller I need to extend ?
  • edited 1:31AM
    What's the error message? Are you just trying to create a normal controller for your site? If so, you should just be able to extend Controller and be sure to call the parent in the constructor if you have one (e.g. parent::Controller()). If using 0.91 branch you need to extend CI_Controller (CI 2.0). For more on controllers visit the CI documentation here:
    http://codeigniter.com/user_guide/general/controllers.html
  • pscpsc
    edited 1:31AM
    At this point I'm just trying to set up a normal model view and controller and learn how to implement the blocks and layouts from Fuel and make sure everything works before I get too deep into new logic.

    I've exteneded CI_controller in the controller file
    I've exteneded Base_module_model in the model file


    I have a php notice in the controller saying that there is an Undefined Property: Mymodel::$My_model

    Filename: controllers/mymodel.php
  • edited 1:31AM
    I'm not quite sure what that issue is from wand would need to see your controller file to assess the problem. You can find my email address here: http://www.getfuelcms.com/forums/profile/1/admin

    Also, If you are using the 0.91 branch that uses CI 2.0 then the contstructor needs to look like the following:
    parent::__construct();
  • edited 1:31AM
    I'm having the same problem; created a new controller. Here's the code, as is:
    class Search extends Controller{
    function __construct()
    {
    parent::__construct();
    }
    }

    I get the error: Fatal error: Class 'Controller' not found in /var/www/fuel/fuel/application/controllers/search.php on line 3

    Should I be including anything?
  • edited February 2011
    Try extending CI_Controller:
    class Search extends CI_Controller{ function __construct() { parent::__construct(); }

    That's a CI 2 change.
  • edited 1:31AM
    Ah my bad, still not used to the CI 2 changes. Thanks!
  • edited 1:31AM
    No worries. It's a CI 2.0 hazing thing.
Sign In or Register to comment.