Attached is a file with a set of commands to simply list, enable, disable themes in a site. This is the complete set of commands:
theme status Show current status of theme configuration in the site.
theme list List all the available themes for the site.
theme info List all info about a theme.
theme set default Set the default theme.
theme set admin Set the administration theme.
theme enable Enable a theme.
theme disable Disable a theme.
It has been tested with drupal 6.x. Must review if compatible with 5.x and 7.x
I include also a dump of a session using the commands:
$ drush theme list
Nombre Título Enabled/Disabled Predeterminado
STARTERKIT Zen Themer’s Starter Kit disabled No
zen_classic Zen Classic disabled No
marvin Marvin disabled No
minnelli Minnelli disabled No
pushbutton Pushbutton disabled No
chrysalis Chrysalis enabled No
zen Zen enabled Si
bluemarine Bluemarine enabled No
chameleon Chameleon enabled No
garland Garland enabled No
$ drush theme status
Default theme: <em>zen</em>
Administration theme: <em>garland</em>
Other enabled themes: chrysalis bluemarine chameleon garland
$ drush theme info garland
Name: garland
Title: Garland
Description: Tableless, recolorable, multi-column, fluid width theme (default).
Version: 6.13
Core: 6.x
PHP: 4.3.5
Engine: phptemplate
Regions: Left sidebar, Right sidebar, Content, Header, Footer
Features: comment_user_picture, favicon, mission, logo, name, node_user_picture, search, slogan, primary_links, secondary_links
Stylesheets:
media: all
files: themes/garland/style.css
media: print
files: themes/garland/print.css
Scripts:
files: themes/garland/script.js
$ drush theme set default zen
Setting zen as default theme [success]
$ drush theme set admin garland
Setting garland as admin theme [success]
$ drush theme enable marvin
Enabling marvin [success]
$ drush theme disable zen
drush: zen is the default theme. You must set another theme as default before trying to disable this one.
Drush command could not be completed. [error]
$ drush theme disable marvin
Disabling marvin [success]
Comments
Comment #1
jonhattanForgot to say any comment on the code is very welcome as I don't know drush very deeply.
Comment #2
jonhattanNew attached file is tested with drupal versions 5, 6 and 7 (with patch from #537280: D7 compatibility). Changes are:
* added some help text (implementation of
drush_hook_help())* new command:
drush theme list enabled* both
theme listandtheme list enabledhas a new column indicating if it is the administration theme.The only drupal version specific code is the one to show the theme info, as drupal 5 themes does not have the same info object as versions 6 and 7.
Note: in order to use it download the attachment to ~/.drush/theme/theme.drush.inc
Comment #3
jonhattanI've placed the code in my cvs sandbox http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/jonhattan/d...
new changes:
* all strings now go through dt()
* use of new _drush_get_themes()
any suggestion on other features/commands?
Comment #4
macmladen commentedI am fascinated with
drushand use it whenever I can.I was puzzled as why it doesn't handle themes and then I saw your addition. Why is it not part of standard
drush?I tried to implement it but did not succseed: i made
~/drush/theme/folder and placedtheme.drush.incthere but drush did not recognize it?!I tried to move it to
~/drush/and~/drush/includesbut still it didn't work.Can you tell me what am I doing wrong?
You should include some more detailed information on installation and operation of commands. Drush is very powerfull and someone could easily do some irreparable damage so I hope you took precautions like backing up theme prior to upgrade.
Does your theme command works with multisite installation?
People usualy forgot that their subtheme might not work with new version of the theme. They also tend to forget that they changed the original theme in code while not changing name so upgrade could actually destroy developed theme (I've done that).
Comment #5
gojruht commentedHi!
Seems to be a nice hack, but having the same problem here. I downloaded the file, named it theme.drush.inc and put it under ./drush/theme/theme.drush.inc.
Can you provide some additional info on installation, would be very much appreciated!
Thx
Comment #6
jonhattanInstructions in #2:
.drushis a directory inside the home directory of the user you are running drush as. It starts with a dot. It is.drushand is not the directory where you installed drush. It is just drush the standard way of doing it, as explained in drush documentation.Comment #7
gojruht commentedWorks perfectly, thank you for the hint.
Comment #8
barrapontojohnathan version from CVS returns
Fatal error: Call to undefined function _drush_get_themes() in ~/.drush/theme/theme.drush.inc on line 302. 09080 version works alright, anyway.Comment #9
jonhattanbarraponto: this extension works against drush HEAD, where drush_get_themes() was introduced for D7 compat.
Comment #10
manuel garcia commentedThanks jonhattan!
Where are the maintainers of this proyect?? Looks to me this would be a nice feature to have, and looks to be done (or nearly there).
Comment #11
manuel garcia commentedComment #12
moshe weitzman commentedComment #13
ChrisRut commentedSubscribe
Comment #14
rodibox commentedSorry, if I do not understand something, I am using drush usually I think your development is very good.
Inside the Drush directory, I make theme directory and put the file theme.drush.inc
ls -l drush
commands
drush
drush.bat
drush.php
example.drush.inc
example.drushrc.php
includes
LICENSE.txt
README.txt
theme
ls -l drush/theme
theme.drush.inc
But
drush -r /var/www/sitios//DRUPAL6/multidrupal -l sitioprueba.arg theme list
The command 'drush theme list' could not be found. [error]
We must do something more? to run commands theme
Thanks.
Comment #15
matt v. commentedRodibox, see comment #6 above. The directory & file need to go in the .drush directory, which is a subdirectory of your home directory. For example... /home/rodubox/.drush
Comment #16
rodibox commentedSorry I'm more stupid every day
Thank you for the excellent complement, I find it very helpful.
Comment #17
alan d. commentedThe enable + set default are working nicely. a big plus 1 for inclusion
I am running DRUSH commands via the apache user on a multisite install and I'm almost always logged into shell via root. So to help others with that 2 min search to find out how to install this for ANY user, just place it here:
[DRUSH INSTALL DIR]/commands/
eg:
Comment #18
moshe weitzman commentedThis is very nice. I'll bet many people are happily using it.
My hesitation is with adding a parallel set of commands for themes. In Drupal 7, modules and themes are looking more and more alike (and install profiles too). For example, themes can also participate in alter hooks and are now duplicate names are disallowed between modules and themes.
I'd be interested in a patch which unifies modules and themes better (like dl does, for example).
Comment #19
jonhattanAttached is a patch with this change to drush: use `list_themes($refresh=true)` instead of `_system_theme_data()` in `_drush_get_themes()` for both environment.inc and environment_7.inc
=> _system_theme_data() is only for drupal 6. It is not available for d5 and d7.
=> list_themes() is available for all versions, use the database if possible and includes theme status (`_system_theme_data()` doesn't).
Attached also a new version of themes command file with those changes:
* spaces to dashes!
* use db_update for d7 instead of db_query
Moshe: I'll work in unification and/or integration whenever possible. I think of those changes:
* remove `theme-status`
* integrate `theme-list` with `pm-status` or `pm-list` as proposed in #678574-12: Add "pm-" namespace to all of the pm commands. With that integration we loose two columns: Default and Administrative theme. That info can be moved to `status` (core).
* in concordance with the proposal at #679020: Extend `pm-list` to list modules, themes and profiles and filter by project status (enabled|disabled|uninstalled...) `theme-list-enabled` could be `pm-list --status=enabled`.
* `theme-info` can land to a new pm-info (if info command is renamed to pm-releases). New code will be written to provide also pm-info for modules (aka `module-info`)
* `pm-enable` and `pm-disable` will be extended to include `theme-enable` and `theme-disable`
* `theme-set-default` and `theme-set-admin` are theme specific operations and can stay the same, or renamed but there's no place for integration with other commands.
Comment #20
joeebel commentedI installed theme.drush.inc (per #17 - in /root/drush/commands/theme/). I get no output to my ssh login terminal (logged in as root). After the command 'drush theme-status' is entered on the command line in a valid Drupal root directory, it just sits for a few seconds, then the prompt returns.
No output, no results. What did I miss? All other drush functionality is working. Centos 5.4, Apache 2.2, PHP 5.2, MySQL 5.0.
Comment #21
moshe weitzman commentedAnything left to do here?
Comment #22
jonhattanAlready in drush HEAD:
Currently working on a patch for pm-enable/disable for themes.
Pending:
* `theme-status`. could be status-theme although I prefer adding two lines (default and admin theme) to drush status.
* `theme-set-default` & theme-set-admin`. Can stay the same. Is core.drush.inc the place for them?
Comment #23
moshe weitzman commentedIMO, we don't truly need `theme-set-default` & `theme-set-admin`. Folks can use vset for that ... The rest looks good. Adding 2 lines to status sounds good for now.
Comment #24
jonhattan2 lines for status shipped in #693958: Extend pm-enable/disable to manage themes.
vset is fine, in despite of default theme must be already enabled.
happily closing this issue!
For the record:
This issue has been dismissed in favor of a closer integration witih drush package manager which has been worked out in other issues. Drush 3.x will be available soon. Upgrade your installation and remove theme.drush.inc.
This is the change in commands:
Comment #25
jonhattanComment #26
vparfaniuc commentedHi Guys,
I'm trying to install the this extension to drush on my ubuntu machine, but I can't find any ~/.drush/ folder in my hard drive, I was using installation guide described here http://groups.drupal.org/node/23487. Does anyone have any idea of how to install this file in my drush installation way? Thank for your help
Comment #27
Circlefusion1 commented@vparfaniuc
Read jonhatton's last post.
http://drupal.org/node/530780#comment-2513534
His wording might be confusing, but basically Drush 3.0 has features in it that are comparable to jonhatton's proposed theme-* commands.
So you don't need to use his file.
Use the en, dis, pm-* and vset commands instead.
Comment #28
batigolixFor those who find this issue via Google: you can change the themes using the drush' vset command:
For example:
Comment #29
macmladen commentedThis is really fascinating, to see next post after 4 years!
Still, Jonhattan I do believe this one is needed even if gods say it is not! Please just make sure it is compatible with latest 8.x-6.x version.
First of all, commands must be dash connected like
theme-statusand should have abbreviation likethstAs for the commands, I'd suggest some "economy":
Those are redundant or at least should operate differently. While status may be omitted and put all info to
theme-list(makingstatusan alias), you can usestatusjust to listdefaultandadmintheme, and list to give list of all themes, enabled/disabled and added default/admin to those that are default/admin.theme-info List all info about a theme.This is good one and rich one, very nice to avoid the need for browser, but it should not give too much information as on region, CSS and JS the screen could be just too much filled with information that is not too relevant to what you can do with info — it is way to easier to open particular info file for details. But heading information are welcome and also a path to theme (where is it in Drupal and file system) so one can copy path and
cd <paste>to go there.theme-default Set the default theme.theme-admin Set the administration theme.This is shorter, more concise version. Maybe if there is some opposite command like
unsetbut there are not. Maybe if not given argument couldprintand if valid argument is given thenset.These are really not needed as they are included in
enableanddisable.To the drush gods: I can agree to some degree about some of the points but I personally think this is a good thing and helps both beginners and experienced users.