Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用var从模板组件调用Joomla函数_Php_Model View Controller_Function_Joomla - Fatal编程技术网

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);
也许这能帮你-也许这能帮你-