{extends}

Frames the page with a layout instead of its directories' wrappers.

Layouts and components Single tags

Syntax

{extends 'layout'}
{extends $layout}

Parameters

layout
The layout template, named from the application root like a {page} (.pad, else .html). May be an expression the page's PHP set.

Description

{extends 'layout'} makes a page use a layout as its frame. It is not a tag that runs while the page renders: it is resolved in the text while the page is assembled, after the PHP and before anything renders, and taken out. The layout then replaces the frame the page would otherwise get - the _inits.pad and _exits.pad of its directories, and the _common wrapper.

The layout is a template named from the application root, like a {page}; keeping layouts in a directory that starts with an underscore (_layouts/) keeps them from being pages of their own. What the page holds outside its {block} pairs goes where the layout writes @page@ - in front of the layout when it has none. The page's top-level blocks override the layout's blocks of the same name, and {parent} inside one of them brings back the content it overrides. A layout may extend a layout of its own; the chain is followed up to the outermost.

The tag must stand directly in the page's own template, outside any other tag; one found anywhere else - in a snippet, a custom tag, inside an {if} - is an error under the strict check. Under the strict check a block of an extending page that overrides nothing is reported as well. {meta layout='...'} does the same as {extends}.

Because the frame is replaced, a page that extends a layout and is opened on its own shows the layout and nothing of the application's wrapper. Inside a {page}, as in the examples here, the included page is assembled the same way and brings its layout along.

Examples

A page in a layout

The page extends a layout of the application and overrides one of its blocks.

Templateexamples/extends/1-layout.pad
{extends '_layouts/extendsCard'}
{block 'title'}Monthly report{/block}
<p>Sales rose by 4% in September.</p>
Resultopen alone

Monthly report

Sales rose by 4% in September.

Made with PAD

The layout from PHP

The layout's name is an expression - a variable the page's PHP set - and the page overrides two blocks.

Templateexamples/extends/2-expression.pad
{extends $layout}
{block 'title'}Order 10417{/block}
{block 'footer'}Shipped on 1 October 2026{/block}
<p>Two kettles and a teapot.</p>
PHPexamples/extends/2-expression.php
<?php

  $layout = '_layouts/extendsCard';

?>
Resultopen alone

Order 10417

Two kettles and a teapot.

Shipped on 1 October 2026

See also

  • {block} A named region of a layout or wrapper - and a page's override of it.
  • {parent} Inside an overriding block: the content of the block it overrides.
  • {meta} The page's metadata - a title, a layout, a cache time or any value - read while the page is assembled.
  • {page} Renders another page of the application - its PHP and its template - in place of the tag.