I'm creating a multi module app. It's a big app that I am porting to Phalcon. It has many different sections, so I am creating a module for each of the main ones.
I do not seem to be able to query a model in one module from a controller in another module. In this example I want to list some members on the home page. The home page is in the main module and the users model is in the users module. I'm using namespaces so in the index controller I have for example,
$this->data['members'] = \App\Users\Models\Members::find();
That produces the following error;
Fatal error: Class 'App\Users\Models\Members' not found in C:\wamp\www\xyz\app\main\controllers\indexController.php on line 12
I've checked and double checked the namespacing is correct. So how can I interact between modules?
So what you need to do is register the namespace of the other module in the Module.php class (or the bootstrap for global availability) for the module you want to query from! Woo hoo - end of head scratching.
Related
I have 2 controller controllers placed in my administration module which are:
modules/administration/controllers/Administration.php
modules/administration/controllers/Customers.php
The problem i have is when i want to display customer details in the admin view via:
echo modules::run('administration/customers/view_all');
I get nothing of course it looks as if codeigniter is looking for a (customers) method inside the administration controller. Has anyone else encountered this issue and knows how to resolve it?
I am writing a module for my site that will manage the Users. So in order to simplify my code, I wrote a "LoginWidget" view and made it accessible thru an actual derived class from CWidget. Now I want to create an URL to the module. For now, I wrote it with the module ID typed in: $this->controller->createUrl("/user/user/login");. But how can I make it more "dynamic"? Let's say I changed the folder name from user to users. What code do I need to use to create an URL, that is relative to the module in which the widget is saved to?
I am using the latest Yii 1.1.x release.
I have used the crud generator of yii successfully for a model named Accounts.
It created the files and everything seems right, but when I navigate to page url it says :
Not Found (#404)
Unable to resolve the request "account".
here is the structure:
backend
models
Accounts
controllers
accountController
Views
account
index
_form
_search
create
update
view
the url /floshal2/backend/web/index.php?r=account
Yii is using camel-case naming mostly. accountController should be "AccountController".
However, it should have been generated that way. I'll open a issue on the tracker...
I'm working in OpenCart 1.5.5 on some sort of newsmodule for in the side bar. I've got it all running in the back-end, but i don't know how i could asign this module module/aselsi to the right side bar on the home page, product page and category page.
I've already looked in some source code's, but i don't fully understand how this particilur thing works.
I did try to make it work by inserting in the DB tabels oc_layout and oc_layout_route some info, but that also didn't work.
So my question is: How can i make my extension / module apear on the front-page?
By running in the back-end I guess You have created a custom controller, model and view for some form where You manage Your news. That is OK.
But since this should be a module You also have to create a backend part for this module so that it could be installed and assigned to the layout on certain pages. The simplest way how to do this is to copy these files:
admin/controller/module/banner.php
admin/language/<YOUR_LANGUAGE>/module/banner.php
admin/view/template/module/banner.php
into Your new
admin/controller/module/aselsi.php
admin/language/<YOUR_LANGUAGE>/module/aselsi.php
admin/view/template/module/aselsi.php
and rename all the class names, constants, model and language file names from banner to aselsi. After this You should see a new Aselsi module under Extensions > Modules in You administration where You should be able to assign this module to pages and positions...
Just want to mention that simple copy-paste + rename is not enough, You would have to edit some other parts as well to get it working.
EDIT: I'm not at the code right now, but yes, You are right, it has a lot to do with that line You are mentioning in comment. Each module setting is saved as serialized string (which is a serialized array) which contains module settings - layout, position, sort_order, etc. The key is the module key - aselsi in Your case, same as all other modules has their own modules. By only installing the module You set the module as active but You can show the module by saving it's settings. In frontend controllers for left, right column and top and bottom content the active modules are then populated and all set to display on that layout and on that position are displayed then.
The installing/uninstalling of module (in backend) can be extended to e.g. add/remove new DB tables for that module and/or for altering current DB tables (by adding new columns, etc.) by implementing install and uninstall methods with their respective logic.
I hope this simple explanation helps a little.
I have been developing with CakePHP and the Alaxos ACL plugin has helped in tremendously.
However, I am facing one issue I am not sure how to fix it?
I added a plugin named 'pages', but I cannot get ACL to see it so it is added to the list of allowed/denied actions.
If I access the plugin thru domain.com/pages/pages I get the following error
DbAcl::check() - Failed ARO/ACO node lookup in permissions check.
When I check thru the ACL plugin display, there is no reference to the pages controller and if I run the ACL build function, it simply says that there is nothing to add.
Is it because this controller is named pages and there is already a pages controller within Cake?
If it is how do I fix it? Is my only option, at this time, adding this manually to the Db? Should I go thru this plugin and rename pages to something else? or is there anything else I should be doing?
Thanks,
I see two things here. First like you suspect, having two classes in your application that share the same name is a bad idea. It will likely give you some problems in one way or another, with the wrong class being instantiated or whatever. As far as Cake does not use namespaces, this is not recommended.
Then, even if you change this name, there will be another problem if the controller you want to manage with ACL is the 'default' controller (a controller that has the same name as the plugin). There was an issue with the ACO nodes retrieval when the path contains twice the same name, which is the case for plugins default controllers.
controllers/Pages/Pages/index
So I decided to just skip the plugins default controllers from the controllers supported by the ACL plugin.
If you are the author of this plugin, you could rename it (because PagesController exists already), and move the actions in some other controller than the default controller.