Preprocess functions allow you to change existing variables, or add new variables, for a template file using PHP code. In this exercise, you'll:
- Define a PHP function that implements a preprocess hook
- Create a new variable named
{{ today }}
that contains the current date and gets passed to the page.html.twig template file.
We recommend that you try the exercise's steps first, and refer to the video if you need help.
We’ve been busy creating tutorials for you! Mostly we've been focusing on Drupal 8 module development, but we've also made updates to our Configuration Management and Drupal 8 Theming series. In addition, we have a fresh batch of Drupal 7 Hands-On Exercises using the Movie Project. Check out what we’ve published or updated in January and February of 2017.
We've done a major overhaul of our React and Drupal tutorials—updating, rewriting, refactoring, and testing all tutorials in the series. It's a great time to learn how to integrate React in a Drupal site!
We’re happy to announce a new kind of series on Drupalize.Me which provides a project for you to practice the skills you’ve learned in Drupal site building, theming, and module development. Our free Hands-On Exercises: Movie Project provides you with wireframes and customer requirements for a movie review site. Each exercise in the series has you progressively build the site according to the specifications. To help you along the way, each lesson also lists some tutorials and learning resources that will show you what kind of knowledge you need to have to accomplish the given tasks.
We’re excited to announce that sandbox environments powered by Tugboat are now live and ready for Drupalize.Me members to use while following our Drupal Views tutorials!
Last week Joe and Blake attended MidCamp 2017 in Chicago. We taught Drupal 8 theming, ate donuts, attended a bunch of sessions, and sprinted on documentation.
Looking Back, Looking Forward
Blog postLast year was a year of waiting for Drupal 8 and working on big changes at Drupalize.Me. Now that we’re into 2016, I want to take a break to reflect on 2015 and take a look at where we’re headed next.
This week, we continue the journey from PSD to Drupal Theme as Emma Jane Westby shows us how to prepare a Drupal site for our theme by generating sample content, customizing image styles, creating and placing blocks, and creating a useful
This week we have a fresh batch of tutorials that cover how to configure Drupal 8 theme settings, how to add a screenshot to your theme, and several methods for how to clear Drupal's cache.
You may have heard some news about the fact that a new theme has been added to Drupal, named Classy. But what kind of theme is it exactly? Is it a pretty new look for Drupal 8? Well, no. You will still see Bartik as the default theme on your Drupal 8 site, so why another theme? Classy is a new base theme in core, which Bartik and Seven will then use as their bases. The idea here is to provide more flexibility to themers when it comes to choosing default CSS classes.
Like many things in Drupal, there are multiple ways to solve the same problem when using Layout Builder. The Layout Builder system is very flexible. In order to be successful when using it, it helps to plan ahead and think through your specific use-case. Picking a pattern, and sticking to it, will help ensure your configuration is more maintainable, and easier for others to understand. While there's nothing to prevent you from mixing and matching, in our experience we've found it's helpful to at least set some ground rules.
In this tutorial we'll outline 3 different patterns to use with Layout Builder, and the pros and cons of each. We'll include:
- Using content fields in scenarios where a few pages use Layout Builder, but the majority of the site's layout is done via the theme and is generally not configurable by editors.
- Using a blocks-based approach to layouts for scenarios where you want to use Layout Builder instead of the traditional blocks and regions approach and allow editors to make changes via the UI.
- And finally, using an Entity view modes approach for sites that rely heavily on Layout Builder and contain lots of interrelated content types with complex layout requirements.
By the end of this tutorial you should have a better understanding of how to approach using Layout Builder for your specific use-case, and the advantages and disadvantages of different common patterns.
Drupal 8 Resources
Blog postThe Drupalize.Me team has been blogging and podcasting about Drupal 8 discussions, features, and significant milestones on the road to beta. Recently, we compiled our Drupal 8 resources here: drupalize.me/drupal-8
Meet Drupal Site Builder Danita Bowman
Blog postDanita has been on Drupal.org and working with Drupal full-time for 4 years. In this interview she answers some questions for us about being a site builder. Meet Danita!
Release Day: Wrapping up Media 2.x
Blog postThis week, we're finishing up our Using Drupal, Chapter 4 series, which covers media management with Media 2. We finish off our site by adding the ability to embed YouTube videos on the site very easily.
Layout Builder
GuideTemplate 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.