Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Downloading and enabling themes is the same as downloading and enabling modules, to a point. I will describe the differences in how to mitigate them. First, let's list the themes that are currently available, drush pml --type=theme. There are four themes and two of them are enabled. However, Drupal themes have some differences for modules, in particular there are default themes which are used unless otherwise specified and admin themes which are used on admin pages only.
The project manage list doesn't show this information. These settings are stored as Drupel site variables. In Drupal development, there are two functions, variable_get and variable_set, that are used to retrieve and save settings and other one-off types of information from hardcoded settings in settings.php and from the database. Drush provides an interface to these site variables with a variable_get and variable_set commands aliased as vget and vset. I will start with variable_get, help vget.
vget takes one argument, the partial or complete name of the variable. If ommited, vget will return all variables. The next bit isn't explicitly documented so I will demonstrate it for you. The default theme is saved in a variable named theme_default. Let's get the value of theme_default now: drush vget theme_default. Currently the default theme is bartik. I am going to switch to the garland theme which is included in core but not enabled.
First, I'll enable garland using project manage command enable garland, drush -y en garland. Then, I will set the variable using the vset command, drush help vset. Variable set has a lot of options, but in the simplest mode it can just set a given value to a particular named variable name. So in this case, drush vset theme_default, to "garland". Theme default is now set to garland.
Verify this by using vget again: drush vget theme_default, and it's set to garland. Switch back to the browser and go to the homepage and reload, make sure that you can see the difference. As the administrative theme is distinct from the theme default there is a different variable, going back to the terminal use vget again, but this time on the variable admin_theme, drush vget admin_theme.
This time two variables will be shown, by default vget searches for variables that contain the search term. To be more specific pass an additional option called Exact, which will only match the exact variable: drush vget admin_theme --exact. This is functional but what if I wanted to change to a different admin theme such as Rubik. Three steps are required, first, download the Rubik theme which also has a soft dependency with the Tao theme.
Usually, dependencies are auto enabled, but in this case it hasn't been explicitly defined by the theme author so it will need to be explicitly downloaded and enabled: drush dl rubik tao. Next, enable the Rubik in Tao themes. So, drush -y en rubik tao. Finally, set Rubik as the admin theme. If there was one exact match, variable set will just set that one variable and will not set the additional variables.
If there is not an exact match, like when a variable has never been set, then the exact option will allow the variable to be set. So in this case I'll just type, drush vset admin_theme rubik. Return to the browser and navigate to the Configuration page to see the difference, which is very striking. I'm going to put the admin theme now back to default: drush reset admin_theme seven.
Going back to the browser and refreshing. And it's back to normal. The vget command can be very useful for tracking changes over time on UNIX like systems. On the configuration page go to site information. Now we will switch back to the terminal for just a moment. By default, variable get will return all variables. I will write every variable in this site to a flat file before I make a change then do a second file and compare the differences to see what was written. This can be useful when storing variables and code, either in settings.php or when explicitly setting a variable in a hook update.
I'm going to give the command "drush vget" and write the output to a file named "before". Next, go to the browser and set the site name to Drush and the slogan to "a command line shell and scripting interface for Drupal". Save the changes then navigate to the site home page. The new site name and slogan are shown. Return to the terminal then dump the variables into a file named "after": drush vget to after.
Finally, use the diff command to show the difference between the two files: diff before after. There are two symbols the greater than symbol indicates that something was written and the less than symbol indicates that something is removed. With this view, I can see that not only were the variables, site name and site slogan, written but so are some other values as well. If I wanted to hardcode these variables in the settings.php I can use another feature of variable get, the pipe option. In this context, I will render the variables as a line of PHP: drush vget site_name --pipe.
And, drush vget site slogan --pipe. I can take these two lines and copy them into settings.php, renaming the dollar $variables to dollar sign $conf to force the site name and slogan to be whatever I specified. For more information on defining variables in the site's settings.php conf array, see drupal.org/node/1525472.
I have demonstrated how to enable, disable, and set the site default and admin team without using the site interface. This can be extremely useful, especially when a mistake was made when developing a theme and a failsafe is needed. In the next segment, I will demonstrate how to manage users, including creating and disabling users, then changing passwords.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101754 Viewers
61 Video lessons · 88515 Viewers
71 Video lessons · 72325 Viewers
56 Video lessons · 104043 Viewers
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.
Your file was successfully uploaded.