0
我无法访问我的ctp文件中的AppController.php函数。Cakephp如何访问ctp文件中的AppController函数?
请检查我的代码:
AppController的
public function commonEmotions($text=null){
$this->loadModel("Sticker");
$this->loadModel("Smiley");
//Smiley
$getSmiley=$this->Smiley->find('all',array('fields'=>array('Smiley.image','Smiley.symbol')));
$emotions=$this->Custom->parseEmotions($text,$getSmiley);
//Sticker
$getSticker = $this->Sticker->find('all',array('fields'=>array('Sticker.uniq_id','Sticker.image')));
$message=$this->Custom->parseStickers($emotions,$getSticker);
return $message;
}
查看/信息/ news_feed.ctp
echo $this->requestAction('/app/commonEmotions/'.$getNewsFeed['News_feed']['news']);
当我运行我的代码我得到fllowing错误
Notice (8): Undefined index: News_feed [APP\View\Messages\news_feed.ctp, line 188]
Warning (2): Missing argument 1 for AppController::commonEmotions() [APP\Controller\AppController.php, line 51]
不要把它放在AppController中。将其放入扩展AppController的特定控制器中。另外:你应该总是提到你正在使用的确切cakephp版本。 – mark 2014-09-26 08:03:58
我觉得'$ getNewsFeed ['News_feed'] ['news']'为空 – 2014-09-26 08:04:34