In this section of the Zid Themes Documentation, we delve into the heart of theme customization: the Twig template engine. Twig offers a powerful and flexible syntax for embedding logic and data into your theme's design. This guide will walk you through the essential syntax, tags, functions, and filters you'll need to create dynamic themes.
Twig's template inheritance feature is instrumental in building a base layout, which can then be extended by child templates for customization. Here's an illustrative example of how to use the extends and block tags within a Zid theme:
In this example, the content block in home.twig will replace the corresponding content block within layout.twig. This pattern of inheritance ensures that you can maintain consistent design elements across different pages while customizing content as needed.Remember that you can also include additional scripts or API calls like zidapi_script within your templates to enhance functionality or track analytics.Now here is an example of a base layout file in Twig, layout.twig, and how it is structured:
This base layout can then be extended by child templates, which can override specific blocks such as title, content, and footer.