0

I want to know how to enable view programmatically in drupal 7? I need it to be exportable with features. I need a snippet code for that. Thanks!

  • Not sure what you actually are looking for, is it just to "enable" a view (that you have somewhere)? If you want to learn from examples (the various pieces it takes for a module to come with a view), then have a look at the sample views that come with the Charts module . – Pierre.Vriens Jul 28 '16 at 14:57
0

Based on your question I honestly think you are doing something wrong, but if you really do have a legit use case I think you can just do this:

$view = views_get_view('machine-name-of-view');
views_export_status($view, TRUE);
views_save_view($view);
  • Thank you very much. I needed it to run hook update that is going ti enable one and disable second view, – Radoslav Curcic Jul 29 '16 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.