Template files in Drupal modules provide the default HTML markup for the visual presentation of a module's data. Be aware that themes are likely to override the template with site-specific customizations. This template should contain only minimal markup to ensure functionality, and document the variables fed into the template.
In this tutorial, we'll:
- Explain the role of Twig template files in modules.
- Show how modules declare and use template files.
- Recognize how a render array can specify a template.
By the end of this tutorial, you should be able to articulate how and when a module should define a new template file.
This week we continue to explore what's new in Drupal 8. We began this series with the Theming, CMI, and OO-PHP editions of our What's New in Drupal 8 series. Last week, we covered what's new in the Entity API, Blocks, Content Authoring Experience, and Mobile and Responsive Features. This week, we have videos outlining what's new in extending Drupal 8 (where did all the hooks go?), new site building features and workflows, and multilingual features. Finally, as a bonus, we have a free video tour of localize.drupal.org, where you can see how Drupal gets translated into languages from all over the world.
March 2017 Tutorial Updates
Blog postMarch was a busy month for us as we continue to work on producing the best Drupal 8 tutorials. We released new tutorials for developers of modules and themes alike.
Let's Debug Twig in Drupal 8!
Blog postWhen I am theming a Drupal site, I need to know which variables are available on a template file. In Drupal 8, the template engine is Twig, so we’re going to need to know a little bit of Twig to make this work. So, if Twig is totally new to you, don’t worry. Today, you’ll learn some Twig!
Release Day: JavaScript in Drupal 8
Blog postWe're happy to announce the addition of several JavaScript-related tutorials to our Drupal 8 Theming guide. These tutorials, along with our other tutorials on defining defining and attaching asset libraries will help you understand Drupal's JavaScript API and help you make sure your custom code follows the established best practices.
Layout Builder, and the related ecosystem of modules, provides a set of powerful tools that allow content creators and site administrators to modify the layout of a page using a drag-and-drop interface. We've published 11 new tutorials on how to use Drupal's Layout Builder to create flexible layouts for your Drupal site.
Release Day: More Twig Tutorials
Blog postThis week, Leanna Pelham of KnpUniversity continues to show you how to become a Twig expert by demonstrating Twig goodies such as template inheritance, functions, tests, for and if syntax, debugging techniques, macros, and other advanced tips and tricks. Each lesson is a bite sized tutorial and includes downloadable site code that will get you up and running with Twig without getting overwhelmed.
Drupal 8.0.0 Released
Blog postIt's finally here! Drupal 8.0.0 was just released, and our team is busy producing new tutorials.
This week we have a ton of new tutorials for you to enjoy. We're very happy to bring back our friends from KnpUniversity to provide a great little series on the Twig templating system, and we're also wrapping up the entire O'Reilly Using Drupal book series with the final tutorials.
We're super excited to release a new series this week, which has been a highly requested one on our suggestion list: PSD to Drupal Theme. This series walks you through the process of converting a static design into a Drupal theme. We'll be covering strategies for breaking down your design into Drupal pieces, extracting your design assets, and working with those components in your CSS. Along the way you're going to also be introduced to grid frameworks, Sass, and other very helpful general web development tools. At the end you will have a theme that you can install and enable on your Drupal site. Having a little bit of Drupal site building experience, and a little bit of Web experience (HTML and CSS) will be helpful but it's not required, so if you find the world of Drupal themes mysterious, this is a great series to clear the fog.
14.3. Learning More
FreeHow to find additional material to gain advanced site-building skills.
Drupal 8 Is 1 Year Old
Blog postIt’s hard to believe, but it has been 1 year since Drupal 8.0 was released to the world. We’re celebrating Drupal 8’s first birthday on November 19th by giving FREE access to our full Drupal 8 Migration Guide over the celebration weekend! This Saturday, November 19th through Monday, November 21st you can learn how to use the new core migration system to upgrade your Drupal site or import content from external sources. It’s time to get using Drupal 8!
Just two weeks ago we launched our new format for guides, along with a landing page that presents our guides and topics on one page. This week we’re pleased to add 2 more new guides to the list: Introduction to Drupal and Learn Drupal 8. Both of these guides provide overviews that answer common questions and point you in the right direction to get started with Drupal.
Now that we understand what templates are and how we can use them, let's override some templates! In this tutorial we'll copy the views wrapper template to our theme and override it so that we can customize the markup for the Baseball Players view. Then we'll modify the template so that our view's pager appears both above and below our table of players.
Drupal Events and Membership Giveaways
Blog postWe're thankful to the volunteers around the world who support the community by running camps. We've partnered up with several of them as sponsors and to give away free Drupalize.Me memberships. Get yourself to one of these events and you can win a free month of Drupalize.Me! Here is a list of upcoming events where you can win a free membership in the next 2 months.
We've updated our Configuration Management series with new tutorials on deployment workflows as well as updated tutorials on managing and inspecting configuration with Drush (now with Drush 9 commands). We've also done some re-arranging and moved our tutorials about using Drupal's Configuration API in a module to a new series, Configuration Entities. Finally, we've added a new tutorial on setting up and using Drush Site Aliases, since this is a prerequisite for completing the new tutorial Live vs. Local Configuration Management. Happy configuration managing!
Drupal 8 Survey Insights
Blog postLast month we asked the Drupal community a few questions. We received 243 responses to our survey, and we'd like to share some of the information. While we're not making scientific generalizations from this data, it is an interesting picture of our community nonetheless. A big thank you to everyone who participated in the survey.
Here are 4 things we learned:
In this exercise, we'll continue our template overriding practice by overriding the image field template. We'll consult the Bootstrap documentation and add a responsive image class that will apply to any images uploaded by a user to the field_image
field. Once again, we'll add this class to the classes
array in the set
Twig tag. You should work on the exercise steps below first, and you can refer to the video if you need some help.
How We Archived Outdated Tutorials
Blog postYou might have noticed some changes on Drupalize.Me lately. We’ve just wrapped up a huge content archiving project and I’d like to share what we did and how this will help us move forward with a library of tutorials for Drupal learners that we’re committed to keeping up-to-date.
New Series: Coding for Views
Blog postViews is without a doubt the most popular module on drupal.org, and one of the reasons for it’s popularity is the plethora of modules that enhance the out of the box views experience. These modules add new display options like a calendar or Javascript caoursel, new formatters for existing fields, and even new backends so you can query things other than MySQL. Like Drupal itself views is written to be extended and it’s not uncommon to need to do just that in order to meet your site specific requirements.