Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Version 4.3

[eluser]Developer13[/eluser]
[quote author="wiredesignz" date="1205229410"]If you asked for a tutorial, here we go, I grabbed Developer13's Inktype blog application and ported it over to use modules. Thanks D13 Wink
[/quote]

Nothing is sexier than people using my stuff... even in alpha... :cheese:

[eluser]wiredesignz[/eluser]
Version 4.0.20 is available on the wiki
Changes to the module loader.
Improvements to library loader and changes to allow for CI using include instead of include_once :grrr:

[eluser]shar_[/eluser]
Hello, why i can't load my library from "application/libraries" directory?

My library:
class Test {

function Test()
{
}
}

calling from module:
$this->load->library('Test');

And i have error:
Class 'Test' not found in D:\www\project_name\system\application\libraries\modular_extensions.php on line 251

[eluser]wiredesignz[/eluser]
Version 4.0.21 is available on the wiki
Fixed a problem with loading application libraries. Thanks shar_ Wink

[eluser]a&w[/eluser]
I can see that the first segment of the url to get the controller is handled via the htaccess. CI handles the other segments automatically something like:
base/seg1_controller/seg2_method/seg3_var1/seg4_var2...

I see where calling the method below from the constructor will manually handle getting the 2nd segment. Does this mean that all of the other segments, if passed, must be handled manually, or can CI still do that?


Code:
function init()
    {
        if($this->uri->segment(2)!='')
        {
            $this->method=$this->uri->segment(2);
        }
        else
        {
            $this->method='index';
        }
    }

I noted from this post: http://ellislab.com/forums/viewreply/366296/

That you created something like this:
application/modules/blog/methods/home.php

Which appears to be utilizing segment3. I didn't quite get the organization on that. Where it's located seems more susceptible for naming collisions from another controller within that module. Are you suggesting to use this organization, or keep the method within modules/someModule/controllers/myController1.php


Reading the wiki I was under the impression to do something like:
Code:
app/
      #HMVC files
      helpers/
            modules_helper.php
      libraries/
            modular_extensions.php

      #defaults
      controllers/
            default_controller.php
      models/
            default_model.php
      views/
            default_layout.php

      modules/
            #sample module
            home/
                  controllers/
                        main.php
                        cart.php
                  models/
                  views/

[eluser]wiredesignz[/eluser]
Yes, Each module and or method needs to check the appropriate URI segment for data.

Methods is a sub-directory of the module.

[eluser]Edemilson Lima[/eluser]
@a&w;:

You can use the _remap() function in your default controller to manage your segments and pass them as parameters to your module method. It could be something like this:
Code:
class Default_controller extends Controller {

    function Default_controller() {
        parent::Controller();
    }

    function _remap() {

        // get module and method
        $module_name = $this->uri->segment(1) or $module_name = 'home';
        $method = $this->uri->segment(2) or $method = 'index';

        // load the module
        $module = & modules::load($module_name);

        // call the module method, passing segments as parameters
        $data['content'] = call_user_func_array(array(& $module, $method), array_slice($this->uri->segment_array(), 2));        

        // load other main view partials
        $data['header'] = modules::run('header');
        $data['main_menu'] = modules::run('main_menu');
        $data['footer'] = modules::run('footer');

        // load the main view
        $this->load->view('main_view', $data);
    }

}
I didn't test this yet, but I think it will work.

[eluser]Daeli[/eluser]
Is there to chance to call a controller wich is in a folder that isn't named like the controller with Edemilson Lima's "default_controller"? e.g.:

URL: http://localhost/public/welcome/function

Folder Structure
/modules
 /public
  welcome
  register

**EDIT**
Also i just can't get my core class extensions to work with placing MY_Validation in libraries folder - it's just not working.

**EDIT 2**
This should fix the problem with extending core libraries
Code:
function library($library, $params = NULL)
    {
        if ($library == 'database') return parent::database();
        
        list($path, $library) = modules::path_to($library, $this->_home, 'libraries/');
        
        $_library = strtolower($library);
        
        if (isset($this->_me->$_library))
        {
           return;
         }
        
        if ($path === FALSE)
        {
            $library = ucfirst($library);
            
                
            load_class($library, FALSE);
            $subclass = APPPATH."libraries/".config_item('subclass_prefix').$library.".php";
            if( file_exists($subclass) && !class_exists(config_item('subclass_prefix').$library) )
                load_class($subclass , FALSE);            
            
            $library = 'CI_'.$library;
        }
        else
            modules::load_file($library, $path);
        
        $this->_me->$_library =& new $library($params);
        
        $this->_assign_to_models();
    }

[eluser]wiredesignz[/eluser]
load_class() will load any core subclasses (MY_) automatically, it is not required twice, What it does not do is update the loaded classes registry which can cause you issues elsewhere. The library loader has since been altered.

Try version 4.0.21, Thanks Wink

[eluser]Daeli[/eluser]
Erm problem with $this->CI->validation->set_error_message(). CI cannot find the corresponding error message, when i set the message in a library.




Theme © iAndrew 2016 - Forum software by © MyBB