Viewers: in countries Watching now:
This course teaches web site designers how to take their sites to the next level with a few advanced techniques and the free and open-source Drupal software. Author Tom Geller shows how to configure the most popular add-on modules; use *nix commands and an FTP program to manage a Drupal site on a web server; change its visual appearance using the latest graphical tools; automate and speed through common tasks with Drush; integrate with social media sites; and see how "supermodules" like Panels, Context, Rules, and Features open up new worlds of code-free development.
Drupal 7 Advanced Training was designed as a follow-up to Drupal 7 Essential Training and it also dovetails nicely with our other Drupal courses, such as Drupal 7 Reporting and Visualizing Data and Create Your First Online Store with Drupal Commerce.
In the previous video you saw how a single Drush command can take the place of a dozen clicks when installing a new site. That economy of effort continues as you build and maintain the site as Drush includes commands to install modules, clear caches, manipulate the site database. That is, to pretty near any kind of big site modifications. This video shows you a few common steps in building a site using Drush as well showing off some of its limitations. First, let's take a look around our site. As I mentioned before we were able to name it when you first installed it using Drush as Drush example site, but other than that there's no content, no special content types, or anything like that. It's basically just a stock installation.
One thing I am going to do is I am going to open another window here with drush.org. This is so I can keep the reference behind the other screen and make sure that you click on the correct tab here. I'm using version 5. All right, now we are ready to get going. The first thing we are going to do is grab some modules. Two I use in most sites are Token and Pathauto. I'm already logged into my site and in that directory as you can see. The command that we want is drush pm- download and then the name of the module we want to download.
That takes a minute and then gives us a report back. One interesting thing is I use this pm- download, that's actually the same as dl. Some of these commands have aliases so you can use either the short form or the long form. In this case, pm stand for package manager, which is a common thing in the UNIX world. We will do the same thing with the Pathauto module. Just to prove that they are there in a familiar interface I am going to go back to the web site and click Modules.
Close up the core group and there they are, Pathauto and Token. We could continue here by clicking, but let's go back to our Terminal and enable them there. I do drush pm-enable and then the name of the module. Now Pathauto requires Token, but I'm going to do the same thing that I usually do in the graphical interface. I am going to just say Pathauto and see if it will actually force the dependencies to be enabled as well. And indeed it does. Yup, I want to continue. And we are done.
If we go back to the web interface, we see exactly what we expected, they've been enabled. This screen that lists all of the modules actually exists in Drush as well. It's drush pm-info, but be warned it's a lot of information. As you see it gives information about all the modules and themes that are installed along with their versions and all sorts of other stuff. If you want to cut that down, you can do it with drush pm-info and then the name of the package you want, like let's say Pathauto.
There, much easier. Another thing you can do is drush pm-info and then pipe it; that's the vertical line on your keyboard, through more. That means it'll take that information and put it through the more program in UNIX. Now we can page through it just by pressing the spacebar or escape from it by pressing Q. I will clear the screen to keep this clean. That's an example of a Drush command that doesn't actually change anything, but rather just displays information.
Two more you should know about are drush core-requirements and drush core-status. Interestingly, the second one, core-status, nothing exists exactly like this in the web interface. Now we can combine that ability to look at information and change information using drush. I will give you an example. First, I will clear the screen and then say drush field-info and then say would like to take a look at the fields.
And it tells me all of the fields that are in my site. We can then create a field with drush field-create article. It asks us for a variety of things in an interactive manner. I will just call it twitter_promo. We want it to be a text field so that's number 13, and we have only one option really, Cancel or add a Text field, so yes. Now it doesn't go through all of the options, because there are so many. Instead it gives you this URL, which you would then copy, but there is something to watch out for.
Be careful that the domain is what it should be. In this case, Drush doesn't exactly know what domain it's on. So I'm going to have to go there myself. It's drush.tomgeller.com, but everything else should be correct. Let's see. Yup, and in fact I can now put in all the other options that I couldn't do very easily with Drush. As you might imagine, Drush cannot only download modules but also themes. I will do that very quickly. First, let's decide on what theme we want to get. I am going to go to drupal.org/project/ themes, and let's see marinelli I think is the one that I want. Yup, there it is! So we know that we want to download marinelli, but there's something to watch out for.
What we see here at the top in the title is what's called the human readable name of the theme or module we want. As you might remember Drupal has both a human readable name and a machine name, and what we need is the machine name. Pretty much always it's going to be the end of this URL, project/marinelli. Another way you can find out the name is by downloading the file itself as I'll do here. Then go back to finder and see what the name is, and yup, there it is, marinelli all lowercase. But I'm not actually going to use those.
Instead, I will go back into my Terminal and download them from that using Drush, once again, and there we go. One interesting thing I want to point out is that when it downloaded the module, it put it into sites > all > modules. In this case, it knew that it was a theme and put it into sites > all > themes. We could find that out by going through the directory, but of course you can also do that on your own time. Let's move on and enable it with drush pm-enable marinelli.
It says, do we really want to do that. Yes, we do. All right, now let's go back to our site and see what happened. Go home and see if we are in the marinelli theme. We are not. Why is that? Well, the thing is you might remember that themes have both enablement and then setting as default, and it didn't actually set as default. All that it did was it took it out of this Disabled Themes area. There is no direct Drush command to set a theme as the default, but Drush can change the value of any variable on your site.
Which means it can effectively check any box or change any setting as you would do the web interface. The trick is in knowing the variable name. Sussing those out is beyond the scope of this video. So I will just show you how to turn this on using the Theme Default variable, which happens to be theme_default. I will go back to my Terminal. First, I will clear the screen and then drush variable-set theme_default, that's the variable name, and marinelli.
Supposedly, it worked, let's go back to our site and make sure. And as you can see, it did. Finally, I want to show you an incredibly useful Drush command that takes the place of pretty much everything that you'll see in the video of about backing up with the Backup and Migrate module. It's called Archive Dump. I go into Terminal and it's simply drush archive-dump. That takes a minute and then it tells us where it put that file. Now you will notice it put it outside of our web apps directory.
It's actually in my home directory/ drush-backups, which it just created. That's good, because you don't want to put it inside with your Drupal site installation. If it did that and then you deleted that by accident you'd have no backup. There is also, by the way, drush archive-restore, which works pretty much exactly as you'd expect. The good thing about the way that Drush does this is it saves both the files and the database, which the Backup and Migrate module doesn't do for example. Well, that sure was a lot, wasn't it? And it should be clear that it's only the tip of the iceberg.
Drush is unbelievably deep and it gets deeper as you install other modules, as many of them include hooks to Drush. You can see some of that by going to Drush.org and clicking Resources. Once there scroll down and you see this Contributed modules with drush integration and once again there are many, many more than that. Drush opens the door to a whole new world of Drupal site management and learning it is a big step to becoming a Drupal professional or just someone with pro-level skills.
There are currently no FAQs about Drupal 7 Advanced Training.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.