Friday, March 19, 2010

[CakePHP] 元件重複利用

靜態頁面


echo $this->renderElement('blah');


動態內容頁面

requestAction

requestAction(string $url, array $options)
You can use requestAction() to retrieve a fully rendered view by passing 'return' in the options: requestAction($url, array('return'));


array based cake style url

$this->requestAction(array('controller' => 'articles', 'action' => 'featured'), array('return'));

This allows the requestAction call to bypass the usage of Router::url which can increase performance.



測試結果只有 $options有給 return才有效,沒給return都是no return (another cake bug??)

No comments: