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

[eluser]wiredesignz[/eluser]
Thanks for that Wink

[eluser]Daniel Dornhardt[/eluser]
Hi,

I am just starting with Code Igniter and it's pretty awesome, mighty flexible, and I like the fact that it doesn't try to force too many constraints on me in what I have to use and where.

So I immediately started out porting my personal pet project (PPP) to CI. Being exposed to django before, I 'hacked' (actually I think it's pretty sound) something similar for PHP.

http://ellislab.com/forums/viewthread/77279/

And it actually works pretty good, it is pretty robust, technically speaking...

And of course I found HMVC, which is the best thing since sliced bread for developing modular CI apps, and of course my 'helper' doesn't help here at all.

What happens is that in order to keep the CI features ($this, etc) working, i need to start a new CI->load->view for each file that gets included.

Now what I did until now (and what doesn't seem to break anything yet) is

Code:
$GLOBALS['CI']->load->view($GLOBALS['TI_CURRENT_BASE_TEMPLATE']);

I discovered this only by looking at the $GLOBALS - array...

But this doesn't work from a module, mainly because of the more or less hardcoded view-path in the loaders.

I already tried different things, like walking the callstack to use the last loader again, but I couldn't figure out a way to properly include the base templates of my little helper.

Maybe a customized Loader would do the trick? If you have any idea, please let me know.

There also was a similar request in this thread already:

http://ellislab.com/forums/viewreply/378523/

Best wishes, may life be good to you.

[eluser]wiredesignz[/eluser]
The Module Loader has two class variables which have reference to the Module home directory and the Module itself. Maybe these will help. Good Luck. Wink

[eluser]Daniel Dornhardt[/eluser]
Hello, next question:

I'm trying to use postdata in my module, but I get an error:


A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Input::$post
Filename: controllers/login_box.php
Line Number: 15

The same call from my contoller does work.

Code:
if ($this->input->post['loginFormSent']) {
  // do stuff
}

Am i doing something wrong? Should it work like this?

[eluser]wiredesignz[/eluser]
$this->input->post is not an array, it's a function/method, ie: $this->input->post('loginformsent');

[eluser]Daniel Dornhardt[/eluser]
Ooops... Smile

Thanks, it worked with those nice round braces Smile

[eluser]tomcode[/eluser]
I don't know whether this is a bug or I'am just doing something wrong, but I was trying to load a library inside a module, which had been loaded already in another module. I got an Fatal Error (cannot redeclare ...).

To avoid this :

file: modules_helper @version: 4.0.26 © Wiredesignz 2008-03-25

method: load_file()

I changed the line 72:
Code:
include_once $path.$file.EXT;


to:
Code:
if( ! class_exists($file) ) include_once $path.$file.EXT;

Now I am quiet and have CI's behaviour back.


Here the complete, changed function:
Code:
/** Load a file
*
* @return array [$config] or [$language]
* @return boolean [TRUE] for class
**/    
function load_file($file, $path, $type = 'class', $result = TRUE)
{
    $file = str_replace(EXT, '', $file);

    if ($type == 'class')
    {
        if( ! class_exists($file) ) include_once $path.$file.EXT;
    }
    else
    {
        include $path.$file.EXT;
        
        if (!isset($$type) OR !is_array($$type))
        {        
            show_error($path.$file.EXT." does not contain a valid {$type} array");
        }
        
        $result = $$type;
    }
    
    log_message('debug', "File loaded: ".$path.$file.EXT);
    return $result;
}

[eluser]wiredesignz[/eluser]
include_once should never reload the same file twice. But the library loader may not be aware that the previous load has occured.

I'll look into this and post back. Thanks Wink

[eluser]tomcode[/eluser]
The library (in fact a model) in question resides in my the main application folder. there is a copy of it in the module folder, which would explain that include_once does not refuse to load.

... I'm in plain middle of building and my app folder's still a mess.

[eluser]wiredesignz[/eluser]
Yes, that would be a problem :lol:

I think I may have to use your code change, let me check it out. Thanks tomcode Wink




Theme © iAndrew 2016 - Forum software by © MyBB