Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)

[eluser]Phil Sturgeon[/eluser]
Get Modular Separation working on CodeIgniter 2.0 with these changes.

[eluser]Muser[/eluser]
[quote author="Vlad0" date="1255720618"]Did anyone tried modular separation with DMZ? It works perfect when DMZ model is in normal models folder but when is in the modules/MODULE/models cannot find it.

I'm not sore is this right topic for this question or it need changes from DataMapper side[/quote]

I think you have to overwrite the Datamapper::autoload() (it is a spl_autoload_register callback function) in order to find the required class inside /modules folder too.

@Wiredesign: Is there any function/method that returns all the module folder names ?

Thank you

[eluser]Phil Sturgeon[/eluser]
[quote author="Muser" date="1269213292"]Is there any function/method that returns all the module folder names ?

Thank you[/quote]

PyroCMS has a module_helper.php for stuff like that

[eluser]Muser[/eluser]
Thank you Phil Sturgeon

This is an example of code to be attached after the last line of Datamapper::autoload() method. This code searches the datamapper model class inside all modulename/models folder:

Code:
// Search in modules
                if(!class_exists($class))
                {
                    $module_dirs = array_keys(Modules::$locations);
                    $modules = array();
                    foreach($module_dirs as $directory)
                    {
                        foreach(glob($directory.'*', GLOB_ONLYDIR) as $module)
                        {
                             $modules[] = $module;
                        }
                    }

                    if(count($modules) > 0)
                    {
                        do {

                            $current_module_folder = array_shift($modules);
                            // Prepare file
                            $file = $current_module_folder  . '/models/' . $class . EXT;

                            // Check if file exists, require_once if it does
                            if (file_exists($file))
                            {
                                    require_once($file);
                            }

                        } while (!class_exists($class) || count($modules) > 0);
                    }

                }

[eluser]Thomas Fuston[/eluser]
'loha!

First of all, thx for this lib.

I really sry for asking a question which was asked twice already. But i really dont see the point why it dont work.

The module name is "admin" and the controller which should be called is "login", so i create a file in
admin module "admin/config/routes.php".

Now i wanna route, example.com/admin to example.com/admin/login, if i am not wrong it should be done by
Code:
$route['admin'] = 'login'

i checked source, but form my point i dont see any mistakes. It seems the routes.php in the module folder are not loaded, 'couse ci loading always the usual routes.php and loading the default_controller in there.

thx so far

[eluser]hugle[/eluser]
Hello,

please try:

Code:
$route['admin'] = 'admin/login';

in: modules/admin/config/routes.php

[eluser]Thomas Fuston[/eluser]
@hugle

already tryed this earlier, but dont work.

EDIT : BAH, stupid me -.- i really dont know why i named route.php instead of routes.php, and didnt saw it by myself , 30 minutes lost doh!

thx for answer

[eluser]TheFunker[/eluser]
Just in case anyone else is getting this error when an unfound controller AND method is entered in the url, i.e. http://www.mysite.com/bad_controller/bad_method

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/MY_Router.php

Line Number: 80

In My_Router.php, change line 80:

Code:
list($module, $directory, $controller) = array_pad($segments, 3, NULL);

to

Code:
list($module, $directory, $controller) = array_pad(array_values($segments), 3, NULL);

[eluser]Prabhjeet[/eluser]
Ok, this is great library to use. It works perfect.

But now i stuck with a problem.

I am using Extjs with codeigniter. Extjs fetches(retrieve, delete or update too) data in codeigniter with query format url, which means i have to set enable_query_strings = true,

for example if normal url will be like this: http://localhost/login/test
then i have to use it with Extjs http://localhost/index.php?c=login&m=test
and it works great.

Now the problem is with modules. now i have the url http://localhost/admin/login/test
'admin' is directory in 'modules' directory.

I'm not getting how to convert it to query string format. I tried everything, but no luck.
Please help.

[eluser]Phil Sturgeon[/eluser]
[quote author="Prabhjeet" date="1270807191"]I'm not getting how to convert it to query string format. I tried everything, but no luck.
Please help.[/quote]

http://www.google.co.uk/search?q=codeign...ery+string

[quote author="TheFunker" date="1269851072"]Just in case anyone else is getting this error when an unfound controller AND method is entered in the url, i.e. http://www.mysite.com/bad_controller/bad_method

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/MY_Router.php

Line Number: 80
[/quote]

Keep an eye on the GitHub repo, I'll update this patch soon.




Theme © iAndrew 2016 - Forum software by © MyBB