Docs > Tags > extends

The <content:extends> tag is used for template inheritance.
A template can only contain one <content:extends> tag, and it must be the first tag in the template. The template attribute names another template from which the current template inherits. Any element of the parent template can be selectively overwritten, matched by id.

For example, consider this master template, called "Template A":
<html>
<head>
<title><page:name/></title>
</head>
<body>
<xyz:header/>
<div id="main"></div>
</body>
</html>
Now look at this template, "Template B", which extends "Template A":
<content:extends template="Template A">
<div id="main">
<h1><content:string id="headline"/></h1>
<content:text name="description" height="100"/>
</div>
This template will inherit all the markup from its parent, but overrides the "main" div with its own markup.

Note that any tag in the parent template can be overriden; it doesn't have to be a <div>, or a child of the <body> tag, but it does have to be uniquely identified by id. It could even be a <content> tag.

A child template can override more than one element in the template it inherits from.


Can't find what you're looking for?

Let us know and we'll see if we can help.