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

[eluser]Avatar[/eluser]
I've added var $modules; to modules_helper.php and modified the modules::run command to add the module string to the $module variable
Code:
class Modules
{    
    var $module;//hold the current module
    var $modules=array();//holds the array of loaded modules array('module_name'=>'module_location')
    function & load($modules, $base = 'controllers/')
    {        
        if(!is_array($modules))
        {
            $modules = array($modules => '');
        }
        
        foreach ($modules as $module => $config)
        {      
        $pos = strrpos($module, '/');
        $mod  = str_replace('/','',substr($module, $pos));
            $this->modules[$mod]=$module; //add module to modules array
and the run command: added $this->module=$module;
Code:
function run($module, $data = '', $method ='index')
    {
        $this->module=$module;//current running module
        $class =& modules::load($module);
        return (method_exists($class,$method))? $class->$method($data) : $class->index($data);
    }
I think this should go had in hand with teh parent as well....but you will know better. Let me know if we can add this. I will do more testing.
#32

[eluser]Avatar[/eluser]
Most likely you will need to add a function to the loader class to load modules just like it does models, helpers and libraries.....Just a thought. Any one awake? I've been blowing this thread up. heheheheheh Smile
Code:
Unable to find the requested file: home_page//views/home_page.php
the library bug I think is connected somehow to the view error above, this is a module within a module
#33

[eluser]wiredesignz[/eluser]
[quote author="badgeek" date="1204665255"]modular extensions rocks!

i have some trouble when loading ci library inside a module

Code:
$this->load->library('pagination');

it gave me

Unable to find the requested file: search_module//libraries/pagination.php

is this a bug?[/quote]

Yes, it is a bug, the loader is expecting to find a pagination module library, I will fix this today. Thanks badgeek Wink
#34

[eluser]Avatar[/eluser]
Notice I don't get these errors and the view loads when loading it like this:

Code:
return $this->smarty_parser->parse('ci:'.$this->environ->template.'home_page',$data,true);
and I have the views folder for each module link to the templates directory(app/views/smarty/templates/$this->environ->template)
by linking I mean in linux command

ln -sf /home/user/public_html/app/views/smarty/templates views

all of the files in the views directory of the modules just became a template for smarty to process right after ci finishes. This is a great thing we have hear folks. Smile If you decide to tdo this with smarty and this great module library then I would highly recommend to keep your names in the views/smarty/templates/template directory to have tpl in the filename so you know if it's a smarty parsable template or just a ci one then the module//views error goes away. Thanks.
#35

[eluser]wiredesignz[/eluser]
Version 4.0.5 will include this addition to modules_helper.php - Thanks badgeek Smile
Code:
//below line 98 ...

    if (class_exists('CI_'.$name)) //CI_Library class is loaded
    {
        return array(FALSE, $name);
    }    
    
    show_error("Unable to find the requested file: ".strtolower($path.$base.$file.EXT));
}

And this change to the library loader in modular_extensions.php
Code:
function library($library, $params = NULL)
{
    if ($library == 'database') return parent::database();
    
    if (is_file(BASEPATH.'libraries/'.$library.EXT))
    {
        load_class($library, FALSE);    //Load the CI_Library class
    }

    list($path, $library) = modules::path_to($library, $this->_path, 'libraries/');
    
    if (isset($this->_module->$library))
    {
       return;
     }
    
    $_library = strtolower($library);
    if ($path === FALSE) $library = 'CI_'.$library; //Use the CI_Library
    
    if(modules::_load_file($library, $path))
    {                
        $this->_module->$_library =& new $library($params);
        $this->_assign_to_models();
    }
}
#36

[eluser]wiredesignz[/eluser]
Version 4.0.5 will also include this addition to modules_helper.php (for yingyes) Tongue
Code:
//below line 47

        //add this module => parent to the modules static array    
        $this->$_module->_modules[$_module] = get_class($this);
        
        return $this->$_module;  
    }
}

And this change to the Module class in modular_extensions.php
Code:
class Module
{        
    var $_modules; //static array($module => $parent)
    
    function Module()
    {
        static $mods = array();
        $this->_modules =& $mods;
        
        $ci =& get_instance();
...
#37

[eluser]Avatar[/eluser]
Smile Thank you my friend.
#38

[eluser]wiredesignz[/eluser]
Version 4.0.5 download is avaiable on the wiki

Thanks to all for your feedback. Wink
#39

[eluser]Avatar[/eluser]
I've modified modular_extensions.php library function see below:
Code:
function library($library, $params = NULL)
    {
        if ($library == 'database') return parent::database();
        
        if (is_file(BASEPATH.'libraries/'.$library.EXT))
        {
            load_class($library, FALSE);
        }

        list($path, $library) = modules::path_to($library, $this->_path, 'libraries/');
        
        if (isset($this->_module->$library))
        {
           return;
         }
        
        
        
        if(modules::_load_file($library, $path))
        {            
            $_library = strtolower($library);
            if ($path === BASEPATH.'libraries/') $library = 'CI_'.$library;
        
            $this->_module->$_library =& new $library($params);
            $this->_assign_to_models();
        }
    }
and on line 87 of modules_helper added to teh array like so:
Code:
foreach (array(MODBASE.$path.$base, MODBASE.$base, MODBASE, APPPATH.$base, APPPATH.$base.$path, BASEPATH.$base, BASEPATH.$base.$path, BASEPATH.$path.$base) as $path2)
this resolves the library bug for the most part unless I've overlooked something. Thank you.
#40

[eluser]Avatar[/eluser]
is there a way we can fix modules:run so we can load modules siblings like this?
Code:
$data['home_page_a']=modules::run('home/home_page/home_page_a',$data);




Theme © iAndrew 2016 - Forum software by © MyBB