So the default behavior of the module is to create an export/views directory filled with .view files that are 'text'-only.
I wrote a function to loop through this directory and uses file_read_contents and eval :( to create the php objects and return them through hook_default_views(). Is there a way we can close this gap so a call to drush views export would be all that is needed?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drush_views_671062-5.patch | 2.38 KB | xjm |
Comments
Comment #1
sethcohn commentedactually, I'd prefer this be 'fixed' with:
1) Custom filename extension (rather than .view) would be good, optionally.
2) (optionally) Add a php start tag to the beginning, and "$views[$view->name] = $view;" to the end of the file
The above additions would mean I could export right into my custom views export directory(ies) (there is a path setting already) and just use my already existing file reading code for hook_views_default_views (which is stock code used by dozens of modules which already do views including in this way)...
This would help support best practices for views rollout in a production environment.
Comment #2
miche+1 to sethcohn's request!
Comment #3
anders.fajerson commentedAlso see http://drupal.org/node/626876
Comment #4
xjm+1, this would be very useful.
Comment #5
xjmAttached patch is against 6.x-3.x-dev. It adds an
--as-includeoption to to thedrush vwexcommand. This option will export the file as a .inc in a format thathook_views_default_views()can load, as described in #1.Works great for me!
(By default, without the
--as-includeflag, files will still be exported in the .view format that drush_views imports.)Comment #6
xjmFor the uninitiated, here's an example of how to include these files after you export them using the patch. I have a teensy module I made called
views_cache.modulethat contains only the following hook:So, I would run the following command to export the "view_name" view to my module's directory, and would see the following output:
Comment #7
pescetti commentedThanks for comments and code, but I consider this issue to depend on #626876: New export syntax: allow export by tag, export to stdout, function header: once that one is closed, it could fulfill this need too; your patch could possibly be reused there as well. Anyway, #626876: New export syntax: allow export by tag, export to stdout, function header will be closed before this one and then it will be possible to better evaluate this issue.
Comment #8
luckysmack commentedsubscribe
Comment #9
jsenich commentedSubscribe.
Comment #10
larowlan+1
Comment #11
pescetti commentedThanks, this functionality is now committed to the 3.x branch, with a more general syntax than the one outlined here.
If you want to export, say, the two views "og_members" and "og_unread", you will use something like:
drush vwex og_members,og_unread --output=includesto produce a file-based export as individual .inc PHP files that can be included by
hook_views_default_views().The old, still default, functionality will use something like:
drush vwex og_members,og_unread --output=files