Joomla组件不调用任何模型函数和控制器函数


joomla component not calling any model function and controller function

我在函数中发送ajax请求并调用模型函数,但模型函数未调用,我也尝试本地控制器函数但不调用任何本地函数

控制器

<?php
    defined('_JEXEC') or die;
    jimport('joomla.application.component.controller');
    class IgalleryController extends JControllerLegacy
    {
        function __construct($config = array())
        {   
            $config['base_path'] = JPATH_SITE.'/components/com_igallery';
            parent::__construct($config);
        }
        function ajaxrequest()
        {
            //JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_igallery/models', 'category');
            //echo $db = JFactory::getDBO();
            $model             = $this->getModel('category');
            $this->params      = JComponentHelper::getParams('com_igallery');
            $this->source      = JRequest::getCmd('igsource', 'component');
            //
            $igid              = JFactory::getApplication()->input->get('igid');
            $Itemid            = JFactory::getApplication()->input->get('Itemid');
            $this->catid       = JRequest::getInt('igid', 0);
            $this->category    = $model->getCategory($this->catid);
            $profileId         = JRequest::getInt('igpid', 0);
            $profileId         = $profileId == 0 ? $this->category->profile : $profileId;
            $user              = JFactory::getUser();
            //print_r($user); die;
            $this->profile     = $model->getProfile($profileId);
            $searchChildren    = JRequest::getInt('igchild', 0);
            $tags              = JRequest::getVar('igtags', '');
            //
            $limit             = JRequest::getInt('iglimit', 0);
            $limit             = $limit == 0 ? 1000 : $limit;
            $foo               = $this->foo();
            print_r($foo);
            $this->photoList = $model->getCategoryImagesList($this->profile, $this->catid, $tags,    $searchChildren, $limit);
            //
            print_r($this->photoList);
        }
        function $this->foo()    
        {
            return true; 
        }   
    ...

在上面的代码中也打印$foo变量,但没有得到 true 或 1 值;

你必须在控制器中覆盖函数 getModel()父模型具有以下构造:

public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true))

您缺少$prefix,如有必要,还可以添加模型文件的包含路径

关于问题返回值 true of false,您必须将 1 回显为 true 的 0 表示 false,并通过 die 函数停止进程。返回方法将显示如此多的 joomla 页面的 html。

function $this->foo()    
    {
       echo 1;
       die;
    }