我有两个不同的问题:
- 呈现默认请求时出错(html)
- 渲染 rss 请求时出错。
这是我的代码:
class PagesController extends AppController {
public $name = 'Pages';
public $components = array('RequestHandler');
public $helpers = array('Text');
}
以下是正常请求的代码。
//problem #1:
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->setDefaultMeta();
$this->layout = 'default';
$this->set(compact('page', 'subpage', 'title_for_layout'));
$this->render(implode('/', $path));
}
这是用于 rss 请求
public function feeds(){
if( $this->RequestHandler->isRss() ){
$this->loadModel('Deal');
$arrId = $this->Deal->DealBuyCondition->listAliveID();
$posts = $this->Deal->rssFeeds($arrId);
return $this->set(compact('posts'));
}
die('rss only');
return false;
}
第一个函数返回错误:
Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, class 'RequestHandlerComponent' does not have a method 'beforeRender' [CORE\Cake\Utility\ObjectCollection.php, line 132]
Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, class 'RequestHandlerComponent' does not have a method 'shutdown' [CORE\Cake\Utility\ObjectCollection.php, line 132]
并且第二个函数没有正确呈现为 RSS。
请帮忙。