CodeIgniter Forums
Modular extensions hmvd bug with same controller name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Modular extensions hmvd bug with same controller name (/showthread.php?tid=39179)

Pages: 1 2


Modular extensions hmvd bug with same controller name - El Forum - 03-03-2011

[eluser]greku13[/eluser]
Hi all,

There is a problem with modular extensions.
When I use
Modules::run($moduleName.'/blocks/'.$methodName, $params);

Because I want to use two controllers that have the same name from two different modules, the second call doesn't work because controller already found (Modules::load - variable alias is the same). Then it doesn't work.

Is there a work around?


Modular extensions hmvd bug with same controller name - El Forum - 03-03-2011

[eluser]InsiteFX[/eluser]
You cannot have two classes with the same name! This is a PHP rule.

It is not a HMVC bug.

InsiteFX


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]greku13[/eluser]
Ok, that's true, I forgot about it.
Then, I think it would be a good idea to name all my class in a module with the module name as prefix.
But then my problem is that the urls will be something like
/mymodule/mymodule_classname/controller
with two times mymodule...
Would it be possible to name the class mymodule_classname, but the url be /mymodule/classname/controller

It is of course possible, but could someone give me some help how to make the change in the source code (where)


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]InsiteFX[/eluser]
Why do you not just give them names that mean something?

Blog
News
Pages
Comments
etc.

InsiteFX


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]wiredesignz[/eluser]
Or use module/config/routes.php if you need that functionality.
Code:
$route['mymodule'] = 'mymodule_classname';



Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]greku13[/eluser]
[quote author="InsiteFX" date="1299333570"]Why do you not just give them names that mean something?

Blog
News
Pages
Comments
etc.

InsiteFX[/quote]

Just because the guy writting module x doesn't know the name of all controllers in all other modules that exists or will exist in the future...


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]greku13[/eluser]
[quote author="wiredesignz" date="1299333727"]Or use module/config/routes.php if you need that functionality.
Code:
$route['mymodule'] = 'mymodule_classname';
[/quote]

I don't really want to update the route file when there is a new module. Is there a rule I can add if I decide that all module names start with "m_" then for example

/m_modulex/blog/index should be routed to /m_modulex/m_modulex_blog/index

but of course that should not impact url not starting with m_

Edit

Sorry, I've just seen, that is in the module itself, so that should do the trick.


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]wiredesignz[/eluser]
Each module can have it's own routes file separate to application/config/routes.php

In any case it looks like your choice of application structure is just creating unnecessary problems. You'll need to figure that out for yourself.


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]greku13[/eluser]
OK

The problem in my application is that I may need to load controllers from different module for partial views, but I must make sure classes have not the same name. So all I see is to prefix all classes with the module name or is there another way?


Modular extensions hmvd bug with same controller name - El Forum - 03-05-2011

[eluser]InsiteFX[/eluser]
And forgive me if you thought I was being rude, I was not. I was just trying to explain that you need some kind of structure for working with modules.

You could create a settings table in your database and add a description etc for modules that are in or added to your application.

InsiteFX