Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)

[eluser]wiredesignz[/eluser]
There is no secret to using MY_ class extensions. Just make sure you follow the CodeIgniter conventions properly.

File naming and class naming rules are especially important.

[eluser]theprodigy[/eluser]
I understand that. I've used them quite a few times. But for some reason, it's not working for me with your Modular Extensions. I would love to continue using it, so I am trying to find out why CI won't load the MY_Model class. MY_Controller works just fine, but the MY_Model won't. It's very strange.

[eluser]theprodigy[/eluser]
Even when trying to use the model when not in a module, it won't load properly.

Maybe it is my setup. I'm not sure. Here is what I have:
MY_Model (located in application/libraries/) :
Code:
<?php
class MY_Model extends Model
{
    #    class variables
    protected $table;
    
    #    Constructor
    public function __construct()
    {
        parent::__construct();
    }
// ...[more code]... //
}

And here is my model inside of my blog module
Code:
<?php
class blog_model extends MY_Model
{
    public function __construct ()
    {
        # code...
        parent::__construct();
        $this->table = 'blog';
    }
    // ...[more code]... //
    
}
and since my MY_Controller works, here it is for comparison.
MY_Controller (located in application/libraries/) :
Code:
<?php
class MY_Controller extends Controller
{
    protected $module;
    protected $controller;
    protected $method;
    protected $inner_view = '';
    protected $template = 'template';
    protected $data = array();
    
    public function __construct()
    {
        parent::__construct();
        
        $this->module = $this->router->fetch_module();
        $this->controller = $this->router->class;
        $this->method = $this->router->method;
        $this->inner_view = $this->module . DIRECTORY_SEPARATOR
                . $this->controller . DIRECTORY_SEPARATOR
                . $this->method;
    }
// ...[more code]... //
}

[eluser]wiredesignz[/eluser]
Well I can assure that using MY_Model works fine with Modular Separation so the problem lies in your code or your installation.

Blog_model class name is important but probably not the issue here.

And the file name should be blog_model.php

MY_Model.php file name is important too.

Call parent::__construct() before other code in the Blog_model class constructor.

[eluser]theprodigy[/eluser]
I found it.

I copied this app from what I thought was a blank version, and I ended up having some left over code in the autoload.php config file.

I removed the autoload, and everything is working as expected. Sorry for the thread spam.

[eluser]CI flea[/eluser]
I have quite a big application which at present uses Matchbox 0.9.3. I've had problems trying to update it to the last version of Matchbox, so decide to try Modular Separation. I was surprised by just removing Matchbox and dropping Modular Separation into my library folder that everything worked, except for one problem I found.

I have separated my views into subfolder for organisational reasons, and everything worked fine. However with Modular Separation I find that if I have a view subfolder with the same name as the Module, it is not able to load these files. A quick change of name for the view subfolder and everything works, however I have hundreds of these across my whole application.

eg.

I have a module called Documents, then in my Views folder I have a subfolder called documents. Modular Separation is not able (and throws no errors) to load files from this subfolder. If I rename my subfolder as document (no s), everything works fine.

I running CI 1.7.2 and php 5.3, with MS 1.11.

I would also like to know if it's possible to move the modules folder from the Application folder to my application root folder.

thanks

[eluser]wiredesignz[/eluser]
[quote author="CI flea" date="1267816876"]... if it's possible to move the modules folder from the Application folder to my application root folder.[/quote]

Use the Modules::$locations array setting. See MY_Router.php

[eluser]CI flea[/eluser]
Thanks,

I've tried to set Modules::$locations but not not had any success yet;

I would like to put the modules folder in the web rot. This is what I've tried so far,
Code:
Modules::$locations = array(
    'path/to/web/' => '../modules/',
);

also tried various combinations of '../modules/', '.modules/', etc.

Thanks

[eluser]Sean Downey[/eluser]
Hi

Thanks for the library it looks great.
In early testing at the moment and came across an issue which I haven't see in the forum thread.

MY_Controller calls
Code:
$this->load->library('member/memberlib');
all good
but in the memberlib.php constructor I call
Code:
$this->CI = &get;_instance();
$this->CI->load->config('memberlib');
I get
Quote:The configuration file userlib.php does not exist.

It works if I use
Code:
$this->CI->load->config('member/memberlib');

but should it work without specifying the module?

Thank you

[eluser]darkhouse[/eluser]
I love this system. It's made my app quite powerful and flexible. I've integrated the modules into a new CMS we're developing. Thank you for providing it.

However, I had a problem where I had a uri '/students/gallery' that was trying to load the gallery module I have (modules/gallery/controllers/gallery) instead of loading the page that the gallery module is used on. The reason is because there is no physical students/gallery page, instead these are slugs in a database, so the router didn't find the page, but did find the module and broke my page.

I solved this by removing the first line in the _validate_request function in the extended router class:

Code:
public function _validate_request($segments) {        
        
    /* locate module controller */
    //if ($located = $this->locate($segments)) return $located; <-- this line

    /* use a default 404 controller */
    if (isset($this->routes['404']) AND $segments = explode('/', $this->routes['404'])) {
        if ($located = $this->locate($segments)) return $located;
    }
    
    /* no controller found */
    //my custom code to load the cms system goes here, instead of showing a 404 error
}

Now everything is working as it should. I just want to confirm that this line is only there so that under normal circumstances, if a physical controller is not found, it will look for a module using that uri, and that by removing it, all I'm losing is the ability to use the uri to load a module. Is that correct?

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB