Php 使用var从模板组件调用Joomla函数
我在我的组件模型中具有以下功能:Php 使用var从模板组件调用Joomla函数,php,model-view-controller,function,joomla,Php,Model View Controller,Function,Joomla,我在我的组件模型中具有以下功能: public function getTotProperty($user){ $database = &JFactory::getDBO(); $database->setQuery("SELECT created_by FROM #__jea_properties WHERE created_by=$user"); $results = $database->loadObjectList();
public function getTotProperty($user){
$database = &JFactory::getDBO();
$database->setQuery("SELECT created_by FROM #__jea_properties WHERE created_by=$user");
$results = $database->loadObjectList();
return $results;
}
我需要从组件的模板调用这个函数。如果没有var$user
,它可以工作:
echo $this->get('TotProperty');
但是我需要在函数中传递var$user
通常,非Joomla方法是getTotProperty($user)代码>
如何将变量$user
从模型传递到模板?您需要先获取模型,然后直接调用该模型上的函数。应在以下视图中执行此操作:
$model = $this->getModel();
echo $model->getTotProperty($user);
您需要首先获取模型,然后直接调用该模型上的函数。应在以下视图中执行此操作:
$model = $this->getModel();
echo $model->getTotProperty($user);
也许这能帮你-也许这能帮你-