2016-02-26 57 views
2

我送的功能的Ajax请求并调用模型功能,但模型的功能没有要求,我也尝试了本地控制器的功能,但不调用任何本地函数的Joomla组件不调用任何型号的功能和控制功能

控制器

<?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的变量,但没有得到真正的或1值;

回答

0

你必须在你的控制器 父模型覆盖功能getModel()具有构造:

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

你缺乏$前缀,你还可以添加包括在必要时

模型文件的路径关于发出返回值true为false,您必须回显1为真为0为false并通过函数停止进程。返回方法将显示如此多的joomla页面的html。

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