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