|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
having trouble with setting simple module structure.Hi, I must say I read the whole manual regarding controllers and most stuff seems pretty straight forward but for some reason I couldn't do the following. From what I see for my needs will be good to have one module for client view and one admin module for admin stuff. 1) I tried using this http://framework.zend.com/manual/en/zend.controller.modular.html point 7.11.2 My structure is as follows - having default + admin module. application default/controllers/IndexController.php admin/controllers/IndexController.php $dir = array( 'default' => PROJECT_ROOT . '/application/default/controllers', 'admin' => PROJECT_ROOT . '/application/admin/controllers' ); $controller = Zend_Controller_Front::getInstance(); $controller->setControllerDirectory($dir); $controller->setParam('noViewRenderer', true); $controller->throwExceptions(true); When I try to launch domain.com/ default module cicks in as is supposed to but when I do domain.com/admin/index/index/ for example....it says File "IndexController.php" was not foundexception 'Zend_Exception' and after some debugging I see it is looking for class Admin_IndexController.php witch probably translates to admin/IndexController.php and not admin/controllers/IndexController.php Can someone lead me to what I do wrong? 2. One more question: This models directory....I kind of miss how it comes together with the whole part. I mean...is there any way to include stuff automatically from there.... can I share automatically same models dir for two modules? Because right now to include something from there I am pretty much include manually stuff - which doesnt make much sense if it is suggested dir stays there. Thanks for time spent Regards |
|
|
Re: having trouble with setting simple module structure.damn, I dig in deeper in mail archive. Turns out controller class should be named <module_name>_ControllerName I my case Admin_IndexController. Filename remains IndexController.php So question 1 is cleared. Someone could elaborate on question 2 would be great. Regards, Julian Davchev wrote: > Hi, > > > > I must say I read the whole manual regarding controllers and most stuff > seems pretty straight forward but for some reason I couldn't do the > following. > > From what I see for my needs will be good to have one module for client > view and one admin module for admin stuff. > > 1) > I tried using this > http://framework.zend.com/manual/en/zend.controller.modular.html > point 7.11.2 > > My structure is as follows - having default + admin module. > > application > default/controllers/IndexController.php > > admin/controllers/IndexController.php > > > $dir = array( > 'default' => PROJECT_ROOT . '/application/default/controllers', > 'admin' => PROJECT_ROOT . '/application/admin/controllers' > ); > > > $controller = Zend_Controller_Front::getInstance(); > $controller->setControllerDirectory($dir); > $controller->setParam('noViewRenderer', true); > $controller->throwExceptions(true); > > > When I try to launch > domain.com/ default module cicks in as is supposed to > > but when I do > domain.com/admin/index/index/ > > for example....it says > File "IndexController.php" was not foundexception 'Zend_Exception' > > and after some debugging I see it is looking for class > Admin_IndexController.php > > witch probably translates to admin/IndexController.php and not > admin/controllers/IndexController.php > > Can someone lead me to what I do wrong? > > > 2. One more question: > This models directory....I kind of miss how it comes together with the > whole part. I mean...is there any way to include > stuff automatically from there.... can I share automatically same models > dir for two modules? > Because right now to include something from there I am pretty much > include manually stuff - which doesnt make much sense if it is suggested > dir stays there. > > Thanks for time spent > > Regards > > > |
|
|
Re: having trouble with setting simple module structure.On question 2: You can create a "global" model directory, or maybe put
global models into your "default" module's model directory. The only important thing is that it is in your include path. But, even better, I can point you toward a solution that popped up on this list yesterday: http://www.nabble.com/Model-Loading-helper-tf3942096s16154.html#a11181598 hope that helps, MF Julian Davchev wrote: > damn, I dig in deeper in mail archive. > Turns out controller class should be named <module_name>_ControllerName > I my case Admin_IndexController. Filename remains IndexController.php > So question 1 is cleared. > > Someone could elaborate on question 2 would be great. > > > > Regards, > > > > Julian Davchev wrote: > >> Hi, >> >> >> >> I must say I read the whole manual regarding controllers and most stuff >> seems pretty straight forward but for some reason I couldn't do the >> following. >> >> From what I see for my needs will be good to have one module for client >> view and one admin module for admin stuff. >> >> 1) >> I tried using this >> http://framework.zend.com/manual/en/zend.controller.modular.html >> point 7.11.2 >> >> My structure is as follows - having default + admin module. >> >> application >> default/controllers/IndexController.php >> >> admin/controllers/IndexController.php >> >> >> $dir = array( >> 'default' => PROJECT_ROOT . '/application/default/controllers', >> 'admin' => PROJECT_ROOT . '/application/admin/controllers' >> ); >> >> >> $controller = Zend_Controller_Front::getInstance(); >> $controller->setControllerDirectory($dir); >> $controller->setParam('noViewRenderer', true); >> $controller->throwExceptions(true); >> >> >> When I try to launch >> domain.com/ default module cicks in as is supposed to >> >> but when I do >> domain.com/admin/index/index/ >> >> for example....it says >> File "IndexController.php" was not foundexception 'Zend_Exception' >> >> and after some debugging I see it is looking for class >> Admin_IndexController.php >> >> witch probably translates to admin/IndexController.php and not >> admin/controllers/IndexController.php >> >> Can someone lead me to what I do wrong? >> >> >> 2. One more question: >> This models directory....I kind of miss how it comes together with the >> whole part. I mean...is there any way to include >> stuff automatically from there.... can I share automatically same models >> dir for two modules? >> Because right now to include something from there I am pretty much >> include manually stuff - which doesnt make much sense if it is suggested >> dir stays there. >> >> Thanks for time spent >> >> Regards >> >> >> >> > > > > -- Maurice Fonk info@... http://naneau.nl/ Scio me nihil scire |
|
|
Re: having trouble with setting simple module structure.-- Julian Davchev <jmut@...> wrote
(on Tuesday, 19 June 2007, 01:43 PM +0300): > My structure is as follows - having default + admin module. > > application > default/controllers/IndexController.php > > admin/controllers/IndexController.php > > > $dir = array( > 'default' => PROJECT_ROOT . '/application/default/controllers', > 'admin' => PROJECT_ROOT . '/application/admin/controllers' > ); > > > $controller = Zend_Controller_Front::getInstance(); > $controller->setControllerDirectory($dir); > $controller->setParam('noViewRenderer', true); > $controller->throwExceptions(true); > > > When I try to launch > domain.com/ default module cicks in as is supposed to > > but when I do > domain.com/admin/index/index/ > > for example....it says > File "IndexController.php" was not foundexception 'Zend_Exception' > > and after some debugging I see it is looking for class > Admin_IndexController.php > > witch probably translates to admin/IndexController.php and not > admin/controllers/IndexController.php Read the documentation closely: except in the default module, modules are namespaced with the module name, which is TitleCased. Thus, admin/controllers/IndexController.php should contain the class Admin_IndexController. > 2. One more question: > This models directory....I kind of miss how it comes together with the > whole part. I mean...is there any way to include > stuff automatically from there.... can I share automatically same models > dir for two modules? > Because right now to include something from there I am pretty much > include manually stuff - which doesnt make much sense if it is suggested > dir stays there. We haven't spent much time on a generic model interface. We suggest placing module specific models in a models subdirectory of your module simply for grouping purposes -- consider, for instance, if you decided to distribute a module, or wanted to restrict access in your repository for certain developers to work only on certain modules -- all the code is then in one place. We don't have any methods yet for automatically including models within a module. It's fairly easy to do it manually: require_once dirname(dirname(__FILE__)) . '/models/MyModel.php'; and I suspect we'll have either an action helper or a method in the action controller post-1.0.0 to make this simpler. -- Matthew Weier O'Phinney PHP Developer | matthew@... Zend - The PHP Company | http://www.zend.com/ |
|
|
Re: having trouble with setting simple module structure.Hey
I dont know whether this is the best way to solve this problem about loading MODELS for a specific MODULE. I had this same question and burned a hell of a time trying to understand what to do. This is the solution i found: i got three modules like this: default -> controllers -> models -> views pro -> controllers -> models -> views public -> controllers -> models -> views Now i needed to load the index model class for the PRO module. And this should happen within the PRO's index action. This is what I came up with: file: /pro/controllers/IndexController.php public function init() { Zend_Loader::loadClass('Pro_Models_Index'); } public function indexAction() { $objIndex = new Pro_Models_Index(); $objIndex->theGreatFunction(); } file: /pro/models/Index.php class Pro_Models_Index { theGreatFunction() { // some code here } } like wise we can use "Default_Models_Index", "Public_Models_Index" or even "Pro_Models_List" which searches for a "/pro/models/List.php" file. You can see I just simply send in the path to models. I found this is a pretty neat way. Let me know if this worked for you :) -- M
|
| Free embeddable forum powered by Nabble | Forum Help |