简体   繁体   中英

CakePHP 1.3 how to render views before displaying content

I'm using CakePHP 1.3. I want to get all html content (table,div..) of my page (.ctp) with CSS to concatinate with other file pdf,

I tried to use something like:

$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');

thank's for helping ..

Please test this code:

/* 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM