Author image
Senior Developer

Using Drush export content type, and views

We're not sure what to do with these: we've written two simple Drush scripts for exporting content types and views. Saving us from having to navigate a few pages and precious seconds.

Download them and pop them somewhere Drush can find them, a good candidate would be in ~/.drush

Then you can run them by typing:

drush export view <view_name>

or

drush export content type <type_name>

You should now either have an error message or and exported view or content type in a file. The files are saved in the current working directory (in most cases where you ran drush from) so you can export views and content types right into your custom modules' include directories.

Comments

It works a little differently than your scripts in that it builds a module to house what it exports and attempts to determine dependencies, but it serves much that same purpose.

This script fails if fieldgroup module is not installed. (Call to undefined function fieldgroup_groups()).

You have to wrap a call to fieldgroup_groups in if module_exists('fieldgroup') statement.

Nice idea. But I got Page not found when trying to download the files.

Doh! Uploaded a tar of the two files.

You may want to look at the features module http://drupal.org/project/features which also provides drush commands to write views and cck fields (and a few other things) to the file system. It works a little differently than your scripts in that it builds a module to house what it exports and attempts to determine dependencies, but it serves much that same purpose.

This can also be handy with http://drupal.org/project/cck_sync

Actually, a contributed module (by me) already exists for this, since the times of Drush version 1.x. There is also a Drush 2.x version, which I released two months ago.

http://drupal.org/project/drush_views

If your code has some interesting features that are not yet in my module, I can consider of course to merge portions of it. Patches or requests through the Drupal Issue Queue for Drush Views are welcome!

well, i would think the rght thing to do is to submit patches to each of cck and views projects so they can ship these commands

There's also the drush system manager module:
http://drupal.org/project/drush_sm

While you're at it, spin up Dark Side of the Moon and The Wizard of Oz...

Brilliant

I'd suggest these get committed to Views and CCK projects, since each module can have their own drush includes packaged with (like Module Builder, and the like).

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.