CakePHP 1.3如何在显示内容之前呈现视图

时间:2017-07-18 11:10:34

标签: php cakephp

我正在使用CakePHP 1.3。我想用CSS获取我的页面(.ctp)的所有html内容(table,div ..)以与其他文件pdf结合,

我尝试使用类似的东西:

$view = new View(null, false);
$view->set('timecard','masque');
$view->viewPath = 'pdf'; 
$output = $view->render('pdf', 'pdf');

OR

$view = new View($this, false);
$view->set(compact('timecard', 'masque'));
$html = $view->render('view_name');

谢谢你的帮助..

1 个答案:

答案 0 :(得分:0)

请测试此代码:

/* Make sure the controller doesn't auto render. */
$this->autoRender = false;

/* Set up new view that won't enter the ClassRegistry */
$view = new View($this, false);
$view->set('text', 'Hello World');
$view->viewPath = 'elements';

/* Grab output into variable without the view actually outputting! */
$view_output = $view->render('box');