1

Is it possible to programmatically delete a display from a view?

The view object has numerous member functions related to displays (add_display, attach_displays, choose_display, set_display, new_display, etc.) and I can also disable a display like this:

<?php
  $view_name = "faq";
  $display_name = "page_1";
  $view = views_get_view($view_name);
  $view->display[$display_name]->display_options['enabled'] = FALSE;
  views_save_view($view);
?>

But I can't see how I can remove the display completely. Can anyone advise? Thanks!

3

This is how you do it. It is how it is done in views_ui_edit_view_form_submit() when you delete a display via the admin UI:

unset($view->display[$display_name]);
  • I should have thought to look there. Thanks - that worked. – Frank H. Aug 11 '15 at 8:23

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.