Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 在joomla中将参数从视图传递到模型_Php_Joomla_Joomla2.5_Joomla Component - Fatal编程技术网

Php 在joomla中将参数从视图传递到模型

Php 在joomla中将参数从视图传递到模型,php,joomla,joomla2.5,joomla-component,Php,Joomla,Joomla2.5,Joomla Component,在joomla定制组件中,一个页面上有多个帖子,每个帖子都包含多条评论,因此在视图中,我想按帖子id调用评论。请建议一个好方法使其工作。您有两个选项。首先,将注释id附加为URL参数,并根据需要在模型中检索它,如下所示: $comment_id = JRequest::getApplication()->input->get('comment_id'); 如果希望在从view类调用模型时传入参数,则需要获取MVC路径模型的实例,而不是使用快捷方法。因此,在JView类中不使用此选项

在joomla定制组件中,一个页面上有多个帖子,每个帖子都包含多条评论,因此在视图中,我想按帖子id调用评论。请建议一个好方法使其工作。

您有两个选项。首先,将注释id附加为URL参数,并根据需要在模型中检索它,如下所示:

$comment_id = JRequest::getApplication()->input->get('comment_id');
如果希望在从view类调用模型时传入参数,则需要获取MVC路径模型的实例,而不是使用快捷方法。因此,在JView类中不使用此选项:

 $this->items = $this->get('Items');
您可以这样做:

$model = $this->getModel();
$this->items = $model->getItems($comment_id);

希望这有帮助。

您有两个选择。首先,将注释id附加为URL参数,并根据需要在模型中检索它,如下所示:

$comment_id = JRequest::getApplication()->input->get('comment_id');
如果希望在从view类调用模型时传入参数,则需要获取MVC路径模型的实例,而不是使用快捷方法。因此,在JView类中不使用此选项:

 $this->items = $this->get('Items');
您可以这样做:

$model = $this->getModel();
$this->items = $model->getItems($comment_id);
希望这有帮助