Is it possible to call directly from a model method from another model of the same component?

Is there any default Joomla option to call in such a way.

有帮助吗?

解决方案

Yes You can

It will not break MVC architecture,

You can check like this

if(!class_exists('VirtueMartModelUser')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'user.php');

            $usermodel = VmModel::getModel('user');

            $currentVMuser = $usermodel->getUser();

First you should include the model file in the required model then create the object. then call like above. This example is Virtue-mart using method

其他提示

According to the my knowledge NO. Otherwise it will break the MVC architecture.

What you can do is

  • Replicate the function you want to use.
  • Make the call from the controller to the both method.

My Advice is to you is even if you figure out a way to do it, Don't do it. It will mess up your whole architecture.

If you have any issues please ask.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top