{restart}
Abandons the page being built and renders another page in its place, in the same request.
Syntax
{restart 'name'}
{restart 'name', $message = 'Saved'}
Parameters
-
page - The page to render instead, named as in a URL.
Description
{restart 'name'} throws away everything the current page has rendered and runs the named page instead - its _inits, PHP, template and _exits - as if it had been asked for. There is no round trip to the browser, so the address bar keeps the original URL, and the request's values are still there.
Variables assigned on the tag - {restart 'list', $message = 'Saved'} - become global variables of the new page; a plain named option is not passed on. From PHP, padRestart ( 'list', [ 'message' => 'Saved' ] ) does the same.
The switch does not happen inside the tag: it records the wish, and the engine starts over at its next step. Pages that keep restarting each other are stopped after twenty restarts with an error. Use {redirect} instead when the browser should end up on the new address - after a form post, so that a reload does not post again.
Examples
Another page instead
When there is nothing to show, the page is replaced by another one in the same request.
{if $count eq 0}
{restart 'empty'}
{/if}
{orders}<p>{$number}</p>{/orders}
Passing values on
Variables assigned on the tag are variables of the page that takes over.
{restart 'orders/list', $notice = 'The order was saved.', $highlight = 42}
See also
- {redirect} Sends the browser to another page or address with a 302 and ends the request.
- {page} Renders another page of the application - its PHP and its template - in place of the tag.
- {exit} Ends the request at once, with an empty body - the PAD way to stop instead of PHP's exit.