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

[eluser]wiredesignz[/eluser]
Version 4.0.6 modules_helper.php will include this fix. Thanks badgeek Wink
Code:
//line 88
        foreach (array(MODBASE.$path.$base, MODBASE.$base, MODBASE.$path, MODBASE,
                       APPPATH.$base, APPPATH.$base.$path) as $path2)
Cut & Paste now so you can keep working.
#52

[eluser]Avatar[/eluser]
I have mine with BASEPATH as well. That's what fixes the // bug with the libraries and helpers I'm sure

Code:
foreach (array(MODBASE.$path.$base, MODBASE.$base, MODBASE, APPPATH.$base, APPPATH.$base.$path, BASEPATH.$base, BASEPATH.$base.$path, BASEPATH.$path.$base) as $path2)
#53

[eluser]Avatar[/eluser]
I've added a function to modules_helper.php
Code:
function to_string($module)
    {
        $_mods=explode('/',$module);
        $pos = strrpos($module, '/');
        $fm  = substr($module, $pos + 1);
        $mod_str='';
        foreach($_mods as $mod => $m)
        {
            if($fm!=$m)
            $mod_str.=$m.'/modules/';
            else
            $mod_str.=$fm.'/'.$fm;
        }
        return $mod_str;
    }
this function lets your load subsequent sibling modules, returns a string that you would normally have to type to get at them modules

works like so
Code:
'content'=>modules::run(modules::to_string('home/home_page/home_page_a'),$data),
then you don't have to type

home/modules/home_page/modules/home_page_a/home_page_a

inside the modules::run();
#54

[eluser]wiredesignz[/eluser]
Nicer for you Tongue
Code:
function to_string($module, $mod_str = '')
{      
    $_mods = explode('/',$module);
        
    $pos = strrpos($module, '/');
    $fm  = substr($module, $pos + 1);
  
    foreach($_mods as $mod => $m)
    {
        $mod_str .= ($fm != $m) ? $m.'/modules/' : $fm.'/'.$fm;
    }
        
    return $mod_str;
}
#55

[eluser]jbowman[/eluser]
having some problems....

application/controllers/admin.php
Code:
<?php

class Admin extends Controller {

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

    function index()
    {
        $data['header'] = modules::run('layout', '', 'header');
        $data['footer'] = modules::run('layout', '', 'footer');
        $this->load->view('admin/main', $data);
    }
}
?>

application/modules/layout/controllers/layout.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Layout extends Module
{
    function Layout()
    {
        parent::Module();
        // modules::debug($this);
    }

    function header($data)
    {
    return $this->load->view('header', '');
    }

    function footer()
    {
    return $this->load->view('footer', '');
    }
}

application/modules/layout/views/header.php
Code:
(large block of html content)

As I understand it, this should display, however, I'm getting An Error Was Encountered

Unable to find the requested file: layout/views/header.php
#56

[eluser]wiredesignz[/eluser]
Double check your paths, it does work for me.
#57

[eluser]Avatar[/eluser]
try to load the view like this:
Code:
return $this->load->view('layout/header');
#58

[eluser]wiredesignz[/eluser]
Version 4.0.6 is available on the wiki
#59

[eluser]Avatar[/eluser]
4.0.6 is broken to loading libraries

had to modifymodular_extensions.php library function to be as 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 had to modify modules_helper.php to look for libraries in BASEPATH as well, see below:
ver 4.0.6 line # 88
Code:
foreach (array(MODBASE.$path.$base, MODBASE.$base, MODBASE.$path, MODBASE, APPPATH.$base, APPPATH.$base.$path, BASEPATH.$base) as $path2)
can we please also add the to_string function to the build?
the line:
Code:
if ($path === FALSE) $library = 'CI_'.$library;
//needs to be
if ($path === BASEPATH.'libraries/') $library = 'CI_'.$library;
//or
if ($path !=FALSE) $library = 'CI_'.$library;
I think that FALSE IS better because then matches for user added lib in app/libs instead of just sys/libs
You be the judge wiredesignz
#60

[eluser]wiredesignz[/eluser]
Which library are you trying to load?

I have tested 4.0.6 and it works fine.

Your modification is searching for library class files that are already loaded. By this code:
Code:
if (is_file(BASEPATH.'libraries/'.$library.EXT))
{
    load_class($library, FALSE);
}

EDIT:
Apologies: There is a file naming issue with apache/linux I need to address.




Theme © iAndrew 2016 - Forum software by © MyBB