Render Page Designer Pages from a Controller

Use the dw.experience.PageMgr API to render pages.

For more information, see:

PageMgr API

Pages are rendered together with their components. You can’t render components separately.

This is the basic code for the page rendering process:

var content = PageMgr.renderPage(cid, null);
// emit content (for example, write to response)

You can put the call to PageMgr.renderPage()in its own controller or add it to an existing controller. To take advantage of SEO URL features, a best practice is to add it to the Page-Show controller.

Page rendering occurs within a nested remote include. If you want to use external parameters in the rendering process, for example, parameters accessible by the controller that calls PageMgr.renderPage(), pass the parameters to the rendering process using a parameters string. For example:

...var params = { /* add your custom parameters here */ };
var content = PageMgr.renderPage(cid, JSON.stringify(params));
// emit content (e.g. write to response)

The remote include that does the rendering doesn't allow passing response headers or cookies set during rendering to the request that called PageMgr.renderPage(). If you need to adjust the response, do so outside of the page rendering process.