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() ?>

As of Wireframe 0.16.0 it's possible to use the setter method as a shortcut for defining both view and view template at the same time. These two are functionally equal:

<?= $page->setViewTemplate('home')->setView('json')->render() ?>
<?= $page->setView('home/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() ?>

Getting or setting Page controller

Page::setController( string|Controller|null $controller ): Page
Page::getController(): Controller|null

Added in Wireframe 0.12.0.

These methods can be used to set or get the Controller class for rendering a Page object. Setter method accepts a name of the controller template ("home" for '"HomeController", "basic-page" for "BasicPageController", etc.), a previously instantiated Controller object, or null (for unsetting the controller). Getter takes no arguments and returns an instance of a Controller class, or null in case a controller couldn't be found.

Example

Example use with dedicated getter/setter methods:

The controller for current page is "<?= $page->getController() ?>".
<?= $page->setController('home')->render() ?>
Back to top