Seems like a pretty obvious feature so figure it must be here somewhere.. but can't for the life of me find it. Also, nothing in issue queue, open or closed.

So, maybe just a new feature request.

Comments

edjay’s picture

if you have enable the "VIEWS UI module" you have access to your views in the site building part of drupal.
There is a list of your views you can override it or disable/delete it.
If you have created your views with the interface you have to export this views in a module then you will be able to disable the views and not delete it.
For the export you have a tool in "TOOLS" section of view where you can mass export views in a module. it gives you the instructions for create a module.

edjay’s picture

OUPSS two comments ^^

liquidcms’s picture

ok, yea i knew i could export it to save it; then delete it.. just seems like it would be easy to just have a setting in UI to disable

thanks.

merlinofchaos’s picture

Version: 6.x-2.6 » 6.x-3.x-dev

Will consider this feature for the 3.x branch.

rooby’s picture

+1 for this feature in the next version

esmerel’s picture

Status: Active » Postponed
dagmar’s picture

Status: Postponed » Needs review
StatusFileSize
new5.62 KB

Here is a first version for this feature.

dawehner’s picture

StatusFileSize
new4.07 KB

The code links fine beside execute_hook_block and execute_hook_menu

I would like to have this feature much deeper in views. I guess view::set_display would be a place to check for it.

This would a) simplify the code and b) make it more robust.

I'm not sure whether this will work.

dagmar’s picture

StatusFileSize
new16.65 KB

Mmm. #8 doesn't work: See attached image.

dagmar’s picture

Title: can i disable a display? » Allow Displays to be disabled
StatusFileSize
new3.19 KB

Ok, this works, as merlinofchaos suggested, check if the display is enabled at build() function is enough to disable a display.

dawehner’s picture

 
+    // Don't allow to use deactivated displays.
+    if (!$this->display[$this->current_display]->handler->get_option('enabled')) {
+      $this->build_info['fail'] = TRUE;
+      return FALSE;
+    }
+

This makes sense. The display plugin takes care to return the right thing if the build failed. For example the page display returns drupal_not_found().

Manual testing worked fine.

$view = new view;
$view->name = 'test_600742';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Node: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['defaults']['enabled'] = FALSE;
$handler->display->display_options['enabled'] = FALSE;
$handler->display->display_options['path'] = 'foo';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_2');
$handler->display->display_options['path'] = 'foo1';

I'm wondering whether it would make sense to move the setting to a button like "remove display".

The rest is RTBC

merlinofchaos’s picture

I'm wondering whether it would make sense to move the setting to a button like "remove display".

Probably yes.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed this. I think we can change the UI in a follow up patch if necessary but it's nice to have the feature.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.