Load frontend model class in admin controller in Opencart - php

I want to load a model class which is in frontend(catalog/model/account/address) in admin controller. I can do it by copying that model to admin's model folder but I want to do it without copying model class.
Is there is any way to do it? or I have to modify the loader class. Any suggestion?
Thanks in advance..

The address methods are available in the catalog side via the admin/model/sale/customer.php file in the admin. Simply use that instead
$this->load->model('sale/customer');
$addresses = $this->model_sale_customer->getAddresses(12345);

Related

Laravel Voyager add additional methods to a BREAD controller

I created a new database through Voyager admin and created BREAD for that table. Now I need to add additional methods to that controller.
I tried to create a custom controller by following this. But the default actions (CRUD) of the controllers are gone.
Without disturbing the existing functionalities of the BREAD I need to add a few more methods in that controller. Is this possible?
I believe you missed to extend voyager's default BREAD controller. for example let say we want to extend a Controller for our Product Model. so we make a ProductController like :
<?php
namespace App\Http\Controllers;
class ProductController extends TCG\Voyager\Http\Controllers\VoyagerBaseController{
//add more functions
}
good luck

How to add a View class for a plugin in cakephp 3?

As the heading to this question states how does one go about adding/integration a View class to a plugin in Cakephp 3?
There is the AppView class for the application but when baking a plugin no View class is included.
There is no View class baked into plugin, because by default plugins are using View class from main application.
If you need to do some specific view-rendering logic in your plugin, you can create eg. YourPluginDir/src/View/CustomView.php and do your things there. You need also to tell your controller to use this View class:
$this->viewBuilder()->setClassName('YourPlugin.Custom');
More info about custom View classes can be found in docs:
Creating your own view classes in CakePHP

How to have a called controller on every page in CodeIgniter

I want to have a controller to do some initial settings and fetch some basic data in all of my application pages (written with PHP and CodeIgniter). As I'm new in CI, please help me to do it.
Some of my goals to have such controller:
Setup submenus (regardless of the current page)
Check user login status.
Notice:
I don't have any problem on creating and working with general Controllers in CI. What I need is something like a hidden controller that does not any need to URI segments to run, and it is not the CI default controller too.
What you can do is create a base controller and and extend that base controller in every other controllers instead of CI_Controller. Your base controller will extend CI_Controller. You can add your required checks in the constructor of the base controller and do stuffs according to that. So every time you call a controller your checks will be done. But you have autoload the base controller. I hope this helps you.

How to add models in controller in my own Modules?(Yii2)

I use Yii2 for create an web application. In this application i need to create my own Module. I create Home module, and put there Module.php class, and 3 folders(MVC). After i configure the application(main.php) and "add" my module.
In controller i load view and test it in browser. Its works fine without using models. When i want to add model in controller, it show some error. Please help me to customize my controller for use model.
I tried this path in controller for model:
app\modules\home\model\MyOwnSuperModel
but it doesnt work, have any ideas?
Thanks.
P.S. Model i create with generator Gii.

Can you use form validation callback in codeigniter when the function is located on different controller?

Let us say I have 2 controllers, the Users controller and the Admin controller. In Users, I am validating a form to check if the user credentials is correct so I created the callback_confirmUser function in form_validation.php and put the confirmUser function in the Users Controller. How can I use this function inside the Admin controller for form validation too?
The only way to do that is to override from the Admin controller. But I don't think that that's the way to go.
Why don't you create a library for that? It's also possible to extend the CI form validation library in case you miss functionality.
See also: http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html and http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html
Good luck!
Edit: it's also possible to use a core controller. You create in the 'core' folder the controller 'MY_Controller.php' that extends the CI_Controller. Instead of extending your controllers from CI_Controller, you extend from MY_Controller. It's than possible to put your validate function in MY_Controller and use it in both admin and user controller.

Categories