Main Template and Subtemplate

In the previous step, we created a rather simple page with a header, a date and a textfield. Most pages require more complex structures, and you'll find yourself creating all kinds of template types. If you always create a full HTML template with header etc., changes to the global layout of your website become unmanageable. To avoid this, webEdition has the concept of main and sub-templates: The main template contains the code that remains identical for all site's pages, while sub-templates are injected into the main template.

The Main Template

<!doctype html>
<html lang="<we:pageLanguage type="language" doc="top" />">
    <we:charset defined="UTF-8">UTF-8</we:charset>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <we:css id="123" comment="inserts a css-stylesheet with the WE-ID 123" />
    <we:js id="124" comment="inserts a javascript with the WE-ID 124" />
    <we:content />

Save this template as main.tmpl (for example). In place of <we:content />, the contents of the sub-template are injected.

Whenever you change the main template now, webEdition asks you whether it should rebuild the child templates.

If you need to fill multiple sections in the page, use the <we:master>- and <we:content>-tag:


<we:content name="preheader"/><!doctype html>
<html lang="<we:pageLanguage type="language" doc="top" />">
    <we:content name="html_header"/>
    <we:content />
    <we:content name="body_end"/>

The Subtemplate


<!-- This is displayed in we:content -->
<!-- // This is displayed in we:content -->
<!-- These are displayed in  the we:content-sections with names -->
<we:master name="preheader"><?php // You could set a http-Header here! ?></we:master>
<we:master name="html_header">
        /* Set individual CSS-Styles for this template only! */
<we:master name="body_end">
        /* This JavaScript is only included in this template  */

Whenever you create a new template, you just define the master template under "Properties".

en/webedition/beginners-guide/main-template.txt · Zuletzt geändert: 2019/02/09 21:35 von Sascha Nemecek

Recent changes RSS feed