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.

Unable to implement HMVC?

May 25, 2013 2:49pm

Subscribe [2]
  • #1 / May 25, 2013 2:49pm

    gRoberts

    298 posts

    Hi all,

    For some reason, I am experiencing issues whilst attempting to install and use Wiredesignz’ HMVC plugin/library and I’ve tried absolutely everything with fail….

    So, from the start, I copy across the MX folder into my `third_party` folder and then copy the MY_ prefixed files into my `core` folder.

    At this point, I get the following error:

    Fatal error: Access to undeclared static property: CI::$APP in /mnt/var/vcap.local/dea/apps/gfwv-0-9ec21c435d3b27396a7090c17847e9eb/app/application/third_party/MX/Loader.php on line 47

    I then change my controller to extend the `MX_Controller` instead of the `CI_Controller` and I then get the following error:

    Fatal error: Cannot redeclare class CI in /mnt/var/vcap.local/dea/apps/gfwv-0-ab605504fa4f243ea48462b4d108e0a4/app/application/third_party/MX/Base.php on line 57

    At this point, I have the vanilla setup, however my controller is within the application/controllers folder.

    Moving my controller to `modules/Front/Front.php` makes no difference what so ever to the above.

    I only have one controller so far, `Front` being the main controller for the site.

    application
    - controllers
    -- Front.php
    - core
    -- MY_loader.php
    -- MY_router.php
    - third_party
    -- MX
    --- Base.php
    --- Ci.php
    --- Config.php
    --- Controller.php
    --- Lang.php
    --- Loader.php
    --- Modules.php
    --- Router.php

    I have absolutely no idea what could be the cause. After searching about, most people are effected because the other controllers are not extending MX_Controller, however I only have one controller, which is:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Front extends MX_Controller {
    
     public function __construct() {
      parent::__construct();
     }
    
     public function page_handler() {
      $this->load->model(array('page_model'));
      $Slug = $this->uri->uri_string();
      
      if($Slug == '') {
       $Page = $this->page_model->GetDefault();
      } else {
       $Page = $this->page_model->GetBySlug($Slug, true);
      }
    
      if(empty($Page)) {
       show_404();
      } else {
       $PageData = array(
        'PageTitle' => $Page->Title,
        'Keywords' => $Page->Keywords,
        'Description' => $Page->Description,
        'Created' => $Page->Created,
        'LastUpdated' => $Page->LastUpdated,
        'Slug' => $Slug,
        'IsDefault' => $Page->IsDefault,
        'PageID' => $Page->PageID
       );
       $this->load->view('templates/' . $Page->TemplatePath, $PageData);
      }
     }
    }
    
    /* End of file Front.php */
    /* Location: ./application/controllers/front.php */

    Any idea’s?

    Many thanks

    Gavin

  • #2 / Jun 07, 2013 5:22pm

    gRoberts

    298 posts

    Anyone?

  • #3 / Jun 12, 2013 3:44am

    XMadMax

    66 posts

    Hey gRoberts,

    I dont’t see the main problem, but….

    You must to rename MY_loader.php to MY_Loader.php, and MY_router.php to MY_Router.php

    Any Modules directories must to be created lowercase (modules/front/front.php)

    Clases must to be declared capitalized:

    class Front extends    .....

    I also recommend to create MY_Controller:

    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    
    /* load the MX_Controller class */
    require APPPATH."third_party/MX/Controller.php";
    class MY_Controller extends MX_controller 
    {
    }

    And any controller extending from MY_Controller

    class Front extends MY_Controller

    I hope this can help.

    Also, you can try XHMVC:  https://bitbucket.org/xperez/codeigniter-cross-modular-extensions-xhmvc , a ready-to-go HMVC with common folders to share yuor development bertweem multiple apps.

     

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

ExpressionEngine News!

#eecms, #events, #releases