ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Modular Extensions - HMVC version 5.3

August 30, 2010 3:03am

Subscribe [81]
  • #106 / Sep 23, 2010 4:07pm

    Peccavio

    55 posts

    Playing around with latest CI 2.0 and HMVC - clean install.

    <Snip>

    So as a test I added a ‘model’ to the ‘welcome’ module and loaded it

    welcome.php

    <?php
    
    class Welcome extends Controller {
    
        function Welcome()
        {
            parent::Controller();    
            $this->load->model('welcome_m');
        }

    Believe you need to do

    class Welcome extends MX_Controller {
    
        function _construct()
        {
            parent::_construct();    
            $this->load->model('welcome_m');
        }
  • #107 / Sep 23, 2010 6:12pm

    wiredesignz

    2882 posts

    @WhIteSidE, The MX_Config issue has been answered earlier in this thread. Please search before asking.

    @coffey, You will need to learn how to upgrade your code to CI 2.0 before learning how to use Modular Extensions.

    @ardinotow, a blank page is due to an error (obviously) stopping your script but not being reported properly. It is a PHP setup problem.

  • #108 / Sep 23, 2010 7:13pm

    coffey

    20 posts

    @wiredesignz, point taken .... but actually this is exactly the process I was starting, I just hadn’t expected this error which is why I removed my module and tried to very simply add a call to a basic model within my working ‘welcome’ controller and when it errored up on the same line instantiating the class - class Welcome_m extends Model - I thought maybe this was something others had experienced.

    But I shall do another totally clean install tomorrow with the latest versions and see what happens… this aboration will doubtless evaporate as they so often do.

  • #109 / Sep 23, 2010 10:55pm

    ardinotow

    162 posts

    @ardinotow, a blank page is due to an error (obviously) stopping your script but not being reported properly. It is a PHP setup problem.

    Have you try using PHP 5.3.1 too and on what OS ? If this is only a PHP setup problem I will not take seriously and start coding with earlier LAMPP version 😊.
    Thanks Wire

  • #110 / Sep 24, 2010 3:35am

    InsiteFX

    6819 posts

    // WRONG!
    class Welcome_m extends Model {
    
    // CORRECT!
    class Welcome_m extends CI_Model {

    InsiteFX

  • #111 / Sep 24, 2010 4:23am

    icomefromthenet

    22 posts

    I was having a problem with blank screen after a install of the new HMVC code (1.7.2), In my case I tracked it down to the /third_party/MX/Config.php file, the config file under System/libraries/config.php was already included (so new file not loaded), so after a rename of the file (not class inside) my problem went away.

  • #112 / Sep 24, 2010 5:30am

    wiredesignz

    2882 posts

    I was having a problem with blank screen after a install of the new HMVC code (1.7.2), In my case I tracked it down to the /third_party/MX/Config.php file, the config file under System/libraries/config.php was already included (so new file not loaded), so after a rename of the file (not class inside) my problem went away.

    And you have broken the installation. Good luck with that.
    File names are not the issue.

  • #113 / Sep 24, 2010 5:41am

    wiredesignz

    2882 posts

    Modular Extensions - HMVC bitbucket wiki is updated.

  • #114 / Sep 24, 2010 6:29am

    coffey

    20 posts

    As you say @inSiteFX

    // WRONG!
    class Welcome_m extends Model {
    
    // CORRECT!
    class Welcome_m extends CI_Model {

    Thanks. It suited me to create a model extending CI_Model (autoloaded via config/autoload).

    <?php if (! defined('BASEPATH')) exit('No direct script access');
    
    // File to contain CRUD functions
    
    class Model extends CI_Model {
    
        function __construct() {
            parent::__construct();
        }
    
    }
    //end of file: Model.php
    //location: /application/models/Model.php

    Really not much of a change here anyway as most of my previous 1.7 module models were in themselves descended from an extended ‘crud’ base model anyway.

  • #115 / Sep 24, 2010 6:32am

    coffey

    20 posts

    BTW big thanks to @wiredesignz for all his fantastic work. Now where is that donate button…..

  • #116 / Sep 24, 2010 6:40am

    wiredesignz

    2882 posts

    Thanks coffey, much appreciated.

  • #117 / Sep 27, 2010 6:45am

    Phil Sturgeon

    2889 posts

    It looks to me like callback functions don’t work when I extend from MX_Controller. My login callback was the one that made me spot this:

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    /**
     * @package     MizuCMS
     * @subpackage     Controllers
     */
    class Dashboard extends CMS_Controller
    {
         // Admin: Control Panel
         function index()
        {
            $this->template->build('cms/dashboard');
        }
        
        // Admin: Log in
        function login()
        {
            // Call validation and set rules
            $this->load->library('form_validation');
    
            // Set the validation rules
            $this->form_validation->set_rules(array(
                array(
                    'field' => 'email',
                    'label' => lang('user_email_label'),
                    'rules' => 'required|trim|callback__check_login'
                ),
                array(
                    'field' => 'password',
                    'label' => lang('user_password_label'),
                    'rules' => 'required|min_length[6]|max_length[20]'
                ),
            ));
    
            // If the validation worked, or the user is already logged in
            if ($this->form_validation->run() or $this->ion_auth->logged_in())
            {
                redirect('cms');
            }
            
            else
            {
                $data->messages['error'] = validation_errors();
            }
            
            $this->template->set_layout(FALSE);
            $this->template->build('cms/login', $data);
        }
        
        function logout()
        {
            $this->ion_auth->logout();
            redirect('cms/login');
        }    
        
        // Callback From: login()
        function _check_login($email)
        {
            if ( ! $this->ion_auth->login($email, $this->input->post('password')))
            {
                $this->form_validation->set_message('_check_login', $this->ion_auth->errors());
                return FALSE;
            }
    
            return TRUE;
        }
    }

    _check_login() is never called at all. I threw a exit(‘hai!’) in the first line of the method and got nothing, I’d have a go debugging the error but I’ve already spent almost an hour of work time getting this far. >.<

  • #118 / Sep 27, 2010 7:02am

    WanWizard

    4475 posts

    Ran into this issue as well.

    The form validation library expects callbacks to be methods of $this->CI (set in the library constructor, when you load the form validation library), which probably points to something else than your module controller…

  • #119 / Sep 27, 2010 7:15am

    wiredesignz

    2882 posts

    I have explained this so many times.
    Set the Form_validation $CI instance to the object you require to respond to callbacks.

    // Call validation and set rules
    $this->load->library('form_validation');
    
    //Set the callback object
    $this->form_validation->CI = $this;
  • #120 / Sep 27, 2010 7:27am

    Phil Sturgeon

    2889 posts

    This doesn’t seem like an amazingly clean solution… Is there no way to build support for this into ME?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases