How to override a box title, and how to learn about what else we can change

Description

Collection: Change Management and Version ControlChapter: How to Override Shared Features and Modify Text

Transcript

What we're going to do in order to demonstrate the next overrides using hooks is use a module called blogoverride that you'll find inside of the resource pack directory. So I'm going to go ahead and copy this and I'm going to jump over to the development folder and I'm going to paste the module in the sites/all/modules/custom folder. Now, if we expand this, we'll see that's our dot info file and our dot module file and then a series of step files which contain progressive enhancements to the dot module file.

So all of these overrides that we're about to demonstrate are being made to the example_blog_feature module which we have in our features folder here. So if you don't have this enabled and installed, you should go ahead and do that now in order to follow along with the next steps. So this first step will override a box title.

Our feature module comes with a box that displays on the blog view page. If we jump back to the browser, we'll see that box right here. It says About Our Blog.

Now, if this were a feature module that we could adjust because it's our own, it's just for our site, we could simply modify this, re-export our feature, and then add that to version control in order to push it to other instances of the site. But what we're doing is considering this feature module as one that will share among multiple sites. So we want to make overrides more carefully.

Let's go ahead and open up the dot module file. It should be blank and then we'll open up the first step which is called blogoverride. module.

override-box-title and let's copy over all of the code in the step file and paste it over the code that's in the dot module file and save it. So let's go ahead and walk through this code line by line. We're first creating a function that's an implementation of hook_boxes_box_load_alter().

So we're just replacing the hook with the name of our module and it gets passed two parameters, box, which is being passed by reference which means that any adjustments that we make to this variable will get passed above to the parent that called this function, and then the delta. So this box variable will contain information about our box that we can adjust. You see we're adjusting a parameter of it down here and then the delta is the machine name that we add through the interface when we create our box initially.

In this series we uncover how to use powerful tools to speed up and stabilize the Drupal development process. We begin with a thorough walk-through of Git, the version control system. After we cover how to patch modules and upgrade Drupal from one minor version to another, we demonstrate how to use the Features module to version control components of Drupal that aren't typically available to version control. Finally, we wrap up with how to integrate Drush - a powerful command line tool for Drupal - into your workflow to speed up the process of doing everything we discussed earlier in the series.

Some of the key points we'll be covering include:

How to use the command line

How to work with the Features module to capture important database changes and make deployment easier.

How to use Git for version control

Best practices for working on a Drupal team

Who this collection is for

This video collection is mainly for developers who want to improve their deployment strategies and learn how to work on a shared Drupal code base with other developers. However, even if you are not a developer, our coverage of using Features and version control is extremely valuable for deploying Drupal sites and sharing reusable components between projects.

Prerequisites

Even if you are not a developer, you will be able to follow with most of this collection. When we talk about code we do not go into detail about the basic components of the code, so you may want to brush up on some coding basics in the "PHP Programming Basics" collection.

It looks like there might be an issue playing videos in this browser. We're working on better cross-brower experience, but in the meantime please try the latest Chrome or Firefox browsers. Or, you may be able to watch the video directly without progress tracking or transcript: