EllisLab text mark
Advanced Search
16 of 24
16
   
Modular Extensions - HMVC version 5.4
Posted: 04 April 2012 01:30 PM   [ # 231 ]   [ Rating: 0 ]
Joined: 2011-06-06
8 posts

hi wiredesignz,

thank you for hmvc library. it is really great, but i need your assistance. i have a structure like this:

application/modules/institutions/controllers/admin/*
application/modules/institutions/controllers/member/*
application/modules/organizations/controllers/admin/*
application/modules/organizations/controllers/member/*
application/modules/users/controllers/admin/*
application/modules/users/controllers/member/*

module users wants to display some content of institutions and organizations. so:

echo Module::run(‘institutions/admin/institutions/get_view’);
echo Module::run(‘organizations/admin/organizations/get_view’);

and everything will be fine. but if you have the same controller name in different modules it won’t.

echo Module::run(‘institutions/admin/institutions/get_view’);
echo Module::run(‘organizations/admin/institutions/get_view’);

it will display the content of first initiated - in this case institutions. but if you make a hack like this:

echo Module::run(‘institutions/admin/institutions/get_view’);
echo Module::run(‘organizations/admin/somenameanythingyouwant/get_view’);

it will work like supposed to. the problem is with Modules.php file LINE 85:

$alias = strtolower(basename($module));

alias is defined by last “dir” entry. i think the problem would exist even if i don’t have such a complex structure, because once loaded controller’s class name will always stay in registry even if it comes from a different module.

can you suggest me a workaround please? i will have duplicate controller names in a structure… thank you very much.

 
Posted: 04 April 2012 05:14 PM   [ # 232 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2937 posts

This problem has nothing to do with Modular Extensions HMVC.

PHP does not allow objects with duplicate class names to exist in the same namespace.

The workaround is not to have duplicate class names.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 04 April 2012 06:38 PM   [ # 233 ]   [ Rating: 0 ]
Joined: 2011-06-06
8 posts

well yes, i knew that, but don’t you think if you’re running (not loading for later use) something it should be properly executed without the impact of environment?

this could be done by recognizing from which module a class is requested or you can run something, execute it (some random temp name) and at the end destroy it. this way, run and load will have much more different meaning and use.

the code line i’ve mentioned makes a name alias with basename function which returns the trailing name of the whole path. so if you have a controller’s subdir structure like i have, and obviously i will have admin and member sections in all modules, i cannot run a module like this: (controller name is the same as module_name)

Modules::run(‘module_name1/subdir/method’);
Modules::run(‘module_name2/subdir/method’);

because instance will be named in both cases as ‘subdir’ which is not true.

 
Posted: 05 April 2012 02:34 AM   [ # 234 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2937 posts
inc - 04 April 2012 06:38 PM

well yes, i knew that, don’t you think if you’re running (not loading for later use) something it should be properly executed without the impact of environment?

this could be done by recognizing from which module a class is requested or you can run something, execute it (some random temp name) and at the end destroy it. this way, run and load will have much more different meaning and use…

You obviously do not understand that while you may be able to destroy objects, you cannot (yet) unload classes.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 05 April 2012 04:01 AM   [ # 235 ]   [ Rating: 0 ]
Joined: 2011-07-30
1 posts

hi, i have question for the hmvc~

There is a not found error from log, when i created a public_controller.php in core folder.
Then, I used it extends MY_controller.

example:
./core
—>MY_Controller.php
—>Public_Controller.php

./modules
-./example
—./controllers
—-./example.php

class example extends Public_Controller{
...

Then, the 404 not found error would be logged.
when i remove the public_controller.php
then, the controller extends “MY_controller”
The 404 not found error would be gone away.~

plz help~~
thx!!!

 

 
Posted: 05 April 2012 04:35 AM   [ # 236 ]   [ Rating: 0 ]
Joined: 2011-06-06
8 posts
wiredesignz - 05 April 2012 02:34 AM

You obviously do not understand that while you may be able to destroy objects, you cannot (yet) unload classes.

“execute it (some random temp name)”. you can assign any name you want right? i mean you’re already doing it. i cannot see anything bad with it. correct me if i’m wrong.

module: organizations.
controller: organizations.
subdir: admin

Modules::run(‘organizations/admin/get’); -> will produce class name Admin.

 
Posted: 05 April 2012 04:52 AM   [ # 237 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2937 posts

@inc, Class names can not be customized at run time.

You appear to be confusing assignable object names with class names.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 12 April 2012 09:14 AM   [ # 238 ]   [ Rating: 0 ]
Joined: 2011-06-06
8 posts
wiredesignz - 05 April 2012 04:52 AM

@inc, Class names can not be customized at run time.

You appear to be confusing assignable object names with class names.

yep, this was my problem and i was confused by that. feeling like a newbie right now smile sorry about that.

but i have a new question:

i wanted to load a rest library with different object name. i did it like this:
$this->load->library(‘rest’, FALSE, ‘rest1’);
$this->load->library(‘rest’, FALSE, ‘rest2’);

but it doesn’t create an rest2 object.

i think the problem is in Loader.php file LINE 139.

 
Posted: 22 April 2012 10:14 AM   [ # 239 ]   [ Rating: 0 ]
Joined: 2012-04-20
3 posts

When installing HMVC, is the provided MY_Loader.php supposed to completely replace the existing MY_Loader.php in application/core?

 
Posted: 22 April 2012 08:18 PM   [ # 240 ]   [ Rating: 0 ]
Joined: 2010-06-26
2 posts

Please add 4 line in config.php then try

$config['modules_locations'= array(
        
APPPATH.'_backend/'  => '../backend/',
        
APPPATH.'_frontend/' => '../frontend/',
    ); 
 
Posted: 24 April 2012 06:21 AM   [ # 241 ]   [ Rating: 0 ]
Joined: 2011-06-24
101 posts

@wiredesignz

May I suggest you put a link on the very first post (erh, maybe on the word ‘bitbucket’) in this thread, that links to HMVC on bitbucket, instead of having us hunt for it?

Now, that would be nice. And when I think about it - user friendly.

 
Posted: 24 April 2012 06:34 AM   [ # 242 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2937 posts

@Sven Delle, The link is in my signature below, it is visible on more than 3000 posts all around these forums.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 24 April 2012 06:52 AM   [ # 243 ]   [ Rating: 0 ]
Joined: 2011-06-24
101 posts

You’re absolute right. This just proves to me that vital information (as in related to the post content) shouldn’t go in the signature.

Do you honestly read all peoples signature when speeding through posts to get information?

Well, maybe you do. But I sure don’t (and I’d guess, others too).

And as it is the nature of html to use links, a user often ‘expect’ a link if it’s relevant. And in this case I think it is.

But in case I owe you an apology - I do apologize : ).

 
Posted: 06 May 2012 12:03 PM   [ # 244 ]   [ Rating: 0 ]
Avatar
Joined: 2012-01-27
1 posts

Hi,
I tried to load a language file in another module in this mode $this->load->language(‘module_name/file_name’); but it doesn’t work. Is there a mode in order to load a language file in another module?

Thanks

EDIT: Solved, it’s work

 
Posted: 14 May 2012 05:47 AM   [ # 245 ]   [ Rating: 0 ]
Joined: 2012-05-14
5 posts

Hi!, is it possible to have two or more controllers in one module.

 
16 of 24
16