DRY Template Layouts and Partials
- 1 - Installation.......
- 2 - Let’s Create a Channel.......
- 3 - Let’s Create a Template.......
- 4 - Using File Fields Part 1: Set Up.......
- 5 - Using File Fields Part 2: Templating.......
- 6 - DRY Template Layouts and Partials.......
- 7 - Moving the System Directory Above Webroot.......
- 8 - Variable Modifiers.......
- 9 - Working with Categories.......
- 10 - Working with Relationships.......
- 11 - Partials, Embeds, Variables.......
- 12 - Let’s Create a Channel Layout.......
- 13 - Routing.......
- 14 - Contact Form.......
- 15 - Adding A 404 Page.......
In this video, we will convert our one file templates to make use of ExpressionEngine’s template layouts and partials
What We Do
- Create our first Template Layout
- Use Layout Variables
- Create Template partials
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
- ExpressionEngine Template Layouts: https://docs.expressionengine.com/latest/templates/layouts.html#template-layouts
- ExpressionEngine Template Layout Variables: https://docs.expressionengine.com/latest/templates/layouts.html#layout-variables
- ExpressionEngine Template Partials: https://docs.expressionengine.com/latest/templates/partials.html
- See all of the site build in action in the Learn EE git repository