Benutzer-Werkzeuge

Webseiten-Werkzeuge


en:webedition:beginners-guide:main-template

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" />">
<head>
    <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:title></we:title>
    <we:description></we:description>
    <we:keywords></we:keywords>
    <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" />
</head>
<body>
 
    <we:content />
 
</body>
</html>

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:

main.tmpl:

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

The Subtemplate

page.tmpl:

<!-- This is displayed in we:content -->
Whatever
<!-- // 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">
    <style>
        /* Set individual CSS-Styles for this template only! */
    </style>
</we:master>
<we:master name="body_end">
    <script>
        /* This JavaScript is only included in this template  */
    </script>
</we:master>

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