views:

227

answers:

1

I'm building a CakePHP site where users can press a button to "save this newsletter as HTML". It seemed like a good idea to use a combination of requestAction and a media view to serve up the content to them, so that they get the exact same content as the live app. The only downside is that requestAction uses an empty layout, so there are no HTML headers or footers.

Is there an easy way, given a string which contains a body of HTML, to build a new string with the full page contents based upon a given layout?

+1  A: 

There is an undocumented feature that if your options array has 0 as the value for the bare key, then the returned results will include the layout:

$newsletter_html = $this->requestAction(
                       array(
                           'controller' => 'Newsletters',
                           'action' => 'view'
                       ),
                       array(
                           'pass' => array($id),
                           'return',
                           'bare' => 0
                       )
                    );
andygeers