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

[eluser]Unknown[/eluser]
For those of you trying to get Modular Separation 2.01 working with CodeIgniter 2.0-dev, you need to extract the MY_Router and MY_Loader files into your application/core directory. Modular Separation will NOT WORK on CI 2.0-dev if you extract it to the application/library folder as per the wiki and readme instructions.

[eluser]bennyhill[/eluser]
Do you still use modules::run('module/controller/method/') to call methods from other modules as you do in Modular Extentions?

[eluser]Ripe[/eluser]
I understand the routes.php inside a module is "local only", is there a way to make it so that the routes file inside a module is actually an extension of the main routes file? Essentially making modules more drop and drag?

To give you a better idea of what I mean, I have a commerce module which has a shopping cart and product listing/management built in. I don't really want to have the url show commerce/cart and commerce/product_list but at the same time I don't want to go into the main routes.php and add
Code:
$route['cart'] = 'commerce/cart';
because then I would have to do this for every module I create and every time I move a module to a new application.

If anyone has any ideas on how to achieve this, I would greatly appreciate it!

[eluser]Brennan Novak[/eluser]
Nifty. I'm digging this much more than the HMVC library. One little thing is coming up that is irking me. I can't seem to echo the base_url() function from any module controller or views it errors out. I never had a problem with this while using the HMVC library. Any thoughts or suggestions would be very much appreciated Smile

[eluser]Jelmer[/eluser]
@Ripe

I've done that by adding the following to the main routes.php config file:
Code:
// Check if first segment corresponds to a module
$segment = substr(load_class('URI')->_parse_request_uri(), 1);
$segment = str_replace(load_class('Config')->item('url_suffix'), '', $segment);
$segment = array_shift(explode('/', $segment));
if ( ! empty($segment) && is_dir(APPPATH.'modules/'.$segment))
    $route[$segment.'(:any)?'] = $segment.'$1';
Which finds the first segment in the $segment variable and only adds the rule when a module of that name exists. So you still need the "local" routes.php files, but the modules will be drag-and-drop.

This could probably be done in a way that's better from a logical point of view (there shouldn't be any programming in the config files), but this works like a charm and works without having to make any changes to the Modular Seperation libs.

EDIT (4 July 2010): I just updated to CI2.0 and that needs a small change to the code above:
Code:
$segment = substr(load_class('URI', 'core')->_parse_request_uri(), 1);
$segment = str_replace(load_class('Config', 'core')->item('url_suffix'), '', $segment);
$segment = array_shift(explode('/', $segment));
if ( ! empty($segment) && is_dir(APPPATH.'modules/'.$segment))
    $route[$segment.'(:any)?'] = $segment.'$1';
The load_class() function needs to know that URI is a core library or it will throw an error.

[eluser]Buso[/eluser]
Could you give me some tips on this? I'm not sure about when I should use modules.

Suppose I want to have a 'comments' module. This module would have its own controllers, models, and views, to handle the comments CRUD. But of course I won't have full pages only for comments, they would be just partial views that I would add to bigger views.
So how can I get the output of this module to use it inside bigger views, if I'm not supposed to make calls between modules? The only thing I have in mind is curl/ajax, but is this the way to go?

Or maybe it isn't a good idea to make a module for comments?

Is it possible to make a module for something like authentication? (knowing that it has to be able to allow/deny access to the whole site if needed)

[eluser]wiredesignz[/eluser]
Use the HMVC feature of Modular Extensions - PHP5 if you require modules to generate view partials.

[eluser]Buso[/eluser]
Has that feature been removed in MS? Why?

[eluser]loosetops[/eluser]
[quote author="Buso" date="1277620721"]Has that feature been removed in MS? Why?[/quote]

It has not been removed. It was never a feature in MS it is a feature of ME. I understand by the design of MS it isn't possible to implement or doing so would make MS dirty and slow.

Also you should be able to design you code so as not to require such a feature, check Phil Sturgeons Template system.

[eluser]Buso[/eluser]
[quote author="loosetops" date="1278224169"][quote author="Buso" date="1277620721"]Has that feature been removed in MS? Why?[/quote]

It has not been removed. It was never a feature in MS it is a feature of ME. I understand by the design of MS it isn't possible to implement or doing so would make MS dirty and slow.

Also you should be able to design you code so as not to require such a feature, check Phil Sturgeons Template system.[/quote]
I have my own theming/templating system, thanks

But I still need the mentioned feature.. And its not something crazy I just came up with, it feels very natural and AFAIK, there are other frameworks/CMSs that have it actually, like ExiteCMS (and as you said, ME has it too).. I'm just trying not to go so far away from CI. If I don't find the solution here I'll write it myself, but it would be nice not to waste time if there are ppl who have already done that.




Theme © iAndrew 2016 - Forum software by © MyBB