By bogeyman on
Hi, I just created some Views and Rules in Drupal 7, then I export them using Rules and Views UI and save them into text files. I need them to be created automatically on my module installation so I don't need to import them manually. Is there any function I can use to import them programmatically?
Comments
Sure - the views part is
Sure - the views part is fairly straight forward. You want to start by exporting the view you want to add to your module. Then in your module you need the following two functions:
I've got a module that loads multiple views so I drop them all into one directory as simple text files and then load each one with a function like this:
Of course another way to do this (or figure out how to do any of the other exports) is to install features
http://drupal.org/project/features
and do a simple feature where you export just a view or a taxonomy set, etc. and use the resulting mini-module as a guide for how you can add this to your own (where I cribbed the above code from)
Key for version used in array returned by YOURMODULE_views_api()
The key for version in the array returned by YOURMODULE_views_api() should be 'api' not 'version':
See: Drupal 7 documentation; Drupal 6 documentation.