DRY Template Layouts and Partials

<<Previous Lesson       Next Lesson>>

In this video, we will convert our one file templates to make use of ExpressionEngine’s template layouts and partials

What We Do

Code Snippets

Basic Template Layout Example

{!-- Our Layout--}
<!DOCTYPE html>
<html>
<head>
    <title>My Site</title>
</head>
<body>
    {layout:contents}
</body>
</html>


{!-- Our code --}
{layout="template_group/template"}

<p>Hello world!</p>

Template Layout With Template Variables

{!-- Our Layout--}
<!DOCTYPE html>
<html>
<head>
    <title>{layout:title}</title>
</head>
<body>
    {layout:contents}
</body>
</html>


{!-- Our code --}
{layout="template_group/template"}

{layout:set name="title"}This title will show up now!{/layout:set}

<p>Hello world!</p>

Links

Discussion and Questions

Doug Black's avatar
Doug Black

Doug is the developer and founder at tripleNERDscore. He is also core contributor to, ExpressionEngine!