Flexible Twig Templates in Craft 2

In this course Ryan teaches the Flexible Template Stack, an approach put together by developer Anthony Colangelo. The Flexible Template Stack in Twig and Craft allows you to have reusable templates that can render content from any section of the site. This is a setup you can use over and over again on your Craft-powered projects.

Start Course
Ryan Irelan

I am the creator of CraftQuest, a web developer, and former software team manager. I spend most of my time improving CraftQuest with code and courses. When I'm not in front of the computer, I spend my time with my family, and running on the roads and trails of Austin, TX.

Flexible Twig Templates in Craft 2 is made up of the following videos:

1IntroductionLet's set the stage for the course, covering what we need and what we'll learn. 03:34
2What We're BuildingWe review the sample site we'll build in this course. 06:06
3Reviewing the Template StackWe use a stack of paper to talk through how the Twig template stack will work. 05:09
4Walking Through Template Stack CodeLet's jump into the code now and step through how the template stack works. 05:06
5Introducing Handler TemplatesHandler templates are the first layer of templates that handler all layouts on the site. Let's review how they work. 02:50
6Entry Handler TemplateThe Entry handler template is used for every single entry view, no matter the section or content. 06:00
7Item Handler TemplateThe Item handler template is used to render the content on listing pages. 04:46
8Matrix Handler TemplateThe Matrix handler template renders all Matrix fields site-wide. 03:29
9Preparing to Code the Template StackWe need to make sure we have everything in place before we start coding our template stack. 01:20
10Reviewing the Supporting TemplatesHandler templates don't work alone. They need help from supporting templates. 03:08
11Creating the Homepage Listing TemplateLet's build our template stack by starting with the homepage. This is a listing template so we'll need to build out our Item handler template. 10:58
12Creating the Included TemplatesThe Included templates do the heavy lifting of rendering the content in the appropriate layouts. 06:55
13Finishing the Homepage Listing TemplateWe wrap up our implementation of the homepage. 09:11
14Completing the Matrix Handler TemplateEarlier we had to create a Matrix handler template stub to get around an error. Let's go back and code that template now. 10:32
15Creating the Entry Handler TemplateIt's time to implement the Entry handler template so we can click through from the homepage and display the single entry views. 12:10
16Testing the Template StackWith our template stack complete let's test it by creating a new content Section and see how it works! 06:11
17ClosingA few words of encouragement and congratulations for completing the course. Confetti not included! 01:03