我已經成功地創建在/控制器訪問的報告/報告CakePHP的 - 使整個頁面爲HTML附加到電子郵件
我現在想創建一個單獨的控制器方法來創建此報告爲HTML文件,並通過電子郵件發送到指定用途。我已經做到了這一點,但碰到了一個障礙。當HTML文件被渲染時,它只是來自/ report方法的視圖元素 - 佈局(包括CSS)不會被渲染。
這裏的基本結構:
public function email_report() {
$render = $this->requestAction('/controller/report');
//$render is then used by fwrite to create a .HTML file, which is then attached to an email
}
public function report() {
//yada yada
//render in report layout rather than default
$this->render('report', 'reports');
}
所以問題是,$僅渲染包含視圖的東西,而不是東西從我的「報告」的佈局。我需要做些什麼才能在我的HTML文件中獲得佈局?
我可以把所有的HTML放在視圖中,但我想在將來使用相同的佈局創建其他報告,並希望避免重複。
您是否嘗試過設置佈局:$ this-> Layout ='default'; – Dave
我剛試過 - 它不起作用。 – gazareth
您是否使用EmailComponent? –