Are there v.5.x version similar to 4.2.05?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 03, 2008 6:10pm
Subscribe [48]#541 / Jul 14, 2008 4:59am
Are there v.5.x version similar to 4.2.05?
#542 / Jul 14, 2008 5:09am
Yes Sam, version 4.2 is based on the new version 5.0
#543 / Jul 14, 2008 5:17am
Some code from Russian community, © AndrewWB.
Allows nested view folders for modules.
modules_helper.php, modules_find():
/** Find a file
*
* Scans for files located anywhere within application/modules directory.
* Also scans application directories for config, controllers, models and views.
* Generates fatal error on file not found.
*
* Hack by Andrew <[email protected]>
*
**/
function modules_find($file, $path = '', $base = 'controllers/', $subpath = '')
{
$spath = '';
if (($pos = strrpos($file, '/')) !== FALSE)
{
$exp = explode('/', $file);
if (is_array($exp) AND sizeof($exp) > 0){
$c = 1;
$size = sizeof($exp);
foreach ($exp as $k => $v){
if ($size > $c){
if ($c > 2) { $spath .= '/'; }
$spath .= $v;
} else {
$file = $v;
}
$c++;
}
}
} else {
$spath = '';
}
($path) AND $path .= '/';
($spath) AND $spath .= '/';
/* scan module directory first */
$paths2scan = array(MODBASE.$path.$base.$spath);
/* then scan application directories for these types */
if (in_array($base, array('controllers/', 'models/', 'views/')))
{
$paths2scan = array_merge($paths2scan, array(APPPATH.$base.$spath, APPPATH.$base.$path.$spath));
}
/* and also scan sub-directories */
if ($subpath)
{
$subpath .= '/';
$paths2scan = array_merge($paths2scan, array(MODBASE.$path.$base.$subpath, APPPATH.$base.$subpath));
}
/* then scan further sub-directories for language */
if (in_array($base, array('language/')))
$paths2scan = array_merge($paths2scan, array(MODBASE.$subpath.$base.$path));
$file_ext = strpos($file, '.') ? $file : $file.EXT;
foreach ($paths2scan as $path2)
{
/* echo '',$path2,$file_ext,''; /* debug paths */
foreach (array($file_ext, ucfirst($file_ext)) as $name)
{
if (is_file($path2.$name))
return array($path2, $file, substr($path, 0, -1));
}
}
/* file not found */
/* don't die just yet, we handle these types back in the caller */
if (in_array($base, array('config/', 'controllers/', 'helpers/', 'language/', 'libraries/', 'plugins/')))
return array(FALSE, $file, FALSE);
/* ok, die now */
show_error("Unable to locate the requested file: ".$path2.$file_ext);
}#544 / Jul 14, 2008 5:24am
Thats weird Sam, modules_find already scans for views in view/sub-directories that match the controller name.
That code does the same job as the code already in modules_find but the extra segment $spath will slow the whole search process.
#545 / Jul 17, 2008 4:49pm
wiredesignz… i’m trying to make a moblogging module using ME as a test.
i just tried loading a plugin (file is in applications/modules/moblog/plugins/pretty_print_pi.php).
the error is can’t load file and the filename has an extra _pi appended to it, so for some reason load_module() in modules_helper gets a request for pretty_print_pi_pi.php and of course, it can find that file. i solved it by just renaming the file with two _pi suffixes, but that is just wrong.
do you know why two suffixes are being added to the plugin filename? is there a fix?
thanks!
#546 / Jul 17, 2008 8:37pm
@Sophistry, you don’t need to use the _pi extension in your code. ME and CI both add the extension for you.
$this->load->plugin('pretty_print');#547 / Jul 17, 2008 11:11pm
yes, sorry for not posting my code snippet! that is what i did, (meaning i have exactly the code you wrote above) but somewhere another _pi is being added. not sure where that is happening except that it is already part of the $file argument sent to modules_load_file() function in the modules_helper.php. (meaning by the time it is getting sent to the modules_load_file() function it already has two _pi suffixes added.
thanks!
#548 / Jul 18, 2008 12:14am
@sophistry, Yes you are totally correct, ME plugin loader has a bug (adds _pi then CI adds _pi)
Try changing these lines in ME Controller
//Controller.php - line 369
list($path, $_plugin) = modules_find($plugin.'_pi', $this->_module, 'plugins/');
//Controller.php - line 378
modules_load_file($_plugin, $path);Let me know how it goes. Thanks sophistry ;)
#549 / Jul 18, 2008 12:01pm
great! that worked. thanks for the fix.
now, back to “plugging” along.
#550 / Jul 18, 2008 12:26pm
@sophistry, Thank you, I will add this fix to next upload. 😉
#551 / Jul 18, 2008 12:46pm
Modular Extensions version 4.2.06 (bugfix) is available on the wiki.
Fixed: plugin filename error. Thanks sophistry 😉
#552 / Jul 20, 2008 12:25am
a quick question i couldn’t find the answer to on the forum or the wiki…
i want to create a MY_directory_helper.php to “extend” the directory helper. When I put that file in the modulename/helper directory it does not load properly - that is, I am not able to use a new function.
i’d like to be able to provide a MY_directory_helper.php along with my module. Is this supported? Can I load MY_ style helper files (and for that matter any other MY_ type extended files)? I see on the forum the limitation with MY_Controller and how it takes over and how it shouldn’t be used with ME, but I didn’t find anything about helpers or other “extendable” files.
BTW, when i put MY_directory_helper.php in the application/helpers directory it works - it provides me the function i’ve defined in the extended file.
thx!
#553 / Jul 20, 2008 12:30am
@sophistry, ME doesn’t check for MY_ extensions in modules, I would consider your helper extension to be a core extension and therefore a shared file, thus locating it in application/helpers would be correct.
#554 / Jul 20, 2008 12:58am
so, if i want to bring in a helper file into the module (and have it exist in the module directories) i should name it /modulename/helpers/whatever_helper.php and then load it up in the controller (for example)? i can load it the normal way? like this:
$this->load->helper('whatever');i’ll update the wiki to note this: “ME doesn’t check for MY_ extensions in modules”
thx.
#555 / Jul 20, 2008 1:05am
Yes, module helpers are loaded in the same fashion as CI helpers, they can be autoloaded via an autoload file ie: {$module_name}/config/autoload.php or they can be autoloaded using a controller class variable
Example:
var $autoload = array('helpers' => array('form','whatever'));