如何在Joomla中添加其他模型的视图

如何在Joomla中添加其他模型的视图

问题描述:

I'm creating a component in Joomla! 3.1.4 which contains multiple models. What I would like to accomplish is to add multiple models B that associate with model A in A's edit view.

To be specific, I want to keep adding unlimited number of model B to connect to model A when I am editing model A. And provide a simple list of B's in A's edit view.

This can of course be done in B's edit views, or fully hard coded within A's edit view. I believe Joomla! should have some methods to accomplish that to avoid code duplications.

Can anyone please shed a light on this? Thanks!

我正在Joomla中创建一个组件! 3.1.4包含多个模型。 我想要完成的是在A的编辑视图中添加多个与模型A关联的模型B. p>

具体来说,我想继续添加无限数量的模型B来连接到 模型A在我编辑模型A时。在A的编辑视图中提供一个简单的B列表。 p>

这当然可以在B的编辑视图中完成,或者在A的编辑中完全硬编码 视图。 我相信Joomla! 应该有一些方法来实现这一目标,以避免代码重复。 p>

任何人都可以对此有所了解吗? 谢谢! p> div>

The Joomla Doc's website covers this subject in the article "Using multiple models in an MVC component"

To call another model from the view, in the view display() method

$modelA = $this->getModel('ModelA');
$modelB = $this->getModel('ModelB');