Page methods

Wireframe injects a bunch of new methods to Page object. This page contains a list of such methods, along with their arguments and return values.

Getting or setting Page layout

Page::layout( [ string $layout ] ): Page|string
Page::setLayout( string $layout ): Page
Page::getLayout(): string

These methods can be used to get or set the layout used to render a Page object. There are separate setter and getter methods, as well as a combined setter/getter method Page::layout() — though it doesn't matter which method you use, using the combined getter/setter may result in less readable code.

Example

Use with combined getter/setter method:

The layout for current page is "<?= $page->layout() ?>".
<?= $page->layout('another-layout')->render() ?>

Example use with dedicated getter/setter methods:

The layout for current page is "<?= $page->getLayout() ?>".
<?= $page->setLayout('another-layout')->render() ?>

Getting or setting Page view

Page::view( [ string $view ] ): Page|string
Page::setView( string $view ): Page
Page::getView(): string

These methods work exactly like their layout counterparts: they can be used to get or set the view used to render a specific Page object.

Example

Example use with combined getter/setter method:

The view for current page is "<?= $page->view() ?>".
<?= $page->view('json')->render() ?>

Example use with dedicated getter/setter methods:

The view for current page is "<?= $page->getView() ?>".
<?= $page->setView('json')->render() ?>

Getting or setting Page view template

Page::viewTemplate( [ string $template ] ): Page|string
Page::setViewTemplate( string $template ): Page
Page::getViewTemplate(): string

Added in Wireframe 0.9.0.

These methods can be used to instruct Wireframe to look for view files under a specific template when rendering a Page object. Just for an example: for a page using template "contact" the default view would usually be /site/templates/views/contact/default.php, but if you use this method before rendering the page, you can instruct Wireframe to swap the template directory (in this example contact) with something else.

Note: "view template" is not a real ProcessWire concept, but rather a term used internally by Wireframe; think of it like "a template used to view a page".

Example

Example use with combined getter/setter method:

The view template for current page is "<?= $page->viewTemplate() ?>".
<?= $page->viewTemplate('home')->render() ?>

Example use with dedicated getter/setter methods:

The view template for current page is "<?= $page->getViewtemplate() ?>".
<?= $page->setViewTemplate('home')->render() ?>
Back to top