• Download Gist
views-skipping-non-default-args-1444474-2.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/handlers/views_handler_argument.inc b/handlers/views_handler_argument.inc
index 3850d0a..6e9646c 100644
--- a/handlers/views_handler_argument.inc
+++ b/handlers/views_handler_argument.inc
@@ -104,6 +104,9 @@ class views_handler_argument extends views_handler {
$this->options['summary_options'] = $options['style_options'];
}
+ if (!empty($options['default_argument_skip_url']) && !isset($options['argument_skip_url'])) {
+ $this->options['argument_skip_url'] = 1;
+ }
if (!empty($options['title']) && !isset($options['title_enable'])) {
$this->options['title_enable'] = 1;
}
@@ -183,6 +186,7 @@ class views_handler_argument extends views_handler {
$options['breadcrumb'] = array('default' => '', 'translatable' => TRUE);
$options['default_argument_type'] = array('default' => 'fixed', 'export' => 'export_plugin');
$options['default_argument_options'] = array('default' => array(), 'export' => FALSE);
+ $options['argument_skip_url'] = array('default' => FALSE);
$options['default_argument_skip_url'] = array('default' => FALSE);
$options['summary_options'] = array('default' => array(), 'export' => FALSE);
$options['summary'] = array(
@@ -461,6 +465,12 @@ class views_handler_argument extends views_handler {
// Copy the now submitted options to their final resting place so they get saved.
$form_state['values']['options']['validate_options'] = $options;
}
+
+ $options =& $form_state['values']['options'];
+ // Clear out the default argument skipping checkbox if the argument skipping is not enabled.
+ if (empty($options['argument_skip_url'])) {
+ $options['default_argument_skip_url'] = 0;
+ }
}
/**
@@ -525,11 +535,17 @@ class views_handler_argument extends views_handler {
$plugins = views_fetch_plugin_data('argument default');
$options = array();
+ $form['argument_skip_url'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Skip argument for view URL'),
+ '#default_value' => $this->options['argument_skip_url'],
+ '#description' => t('Select whether to include this argument when constructing the URL for this view. Skipping arguments is useful e.g. in the case of when the argument is not provided by the URL.'),
+ );
$form['default_argument_skip_url'] = array(
'#type' => 'checkbox',
- '#title' => t('Skip default argument for view URL'),
+ '#title' => t('Skip only default argument for view URL'),
'#default_value' => $this->options['default_argument_skip_url'],
- '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.')
+ '#description' => t('Select whether to skip this argument only in the case of when it is provided as a default argument above. Skipping default arguments is useful e.g. in the case of feeds.'),
+ '#dependency' => array('edit-options-argument-skip-url' => array('1')),
);
$form['default_argument_type'] = array(
diff --git a/includes/view.inc b/includes/view.inc
index 0a2e7bc..3fe42cf 100644
--- a/includes/view.inc
+++ b/includes/view.inc
@@ -1377,7 +1377,8 @@ class view extends views_db_object {
$position = 0;
if (!empty($this->argument)) {
foreach ($this->argument as $argument_id => $argument) {
- if (!empty($argument->is_default) && !empty($argument->options['default_argument_skip_url'])) {
+ // Either we need to skip the argument anyway, or only when it's a default argument.
+ if ((!empty($argument->options['argument_skip_url']) && empty($argument->options['default_argument_skip_url'])) || (!empty($argument->options['default_argument_skip_url']) && !empty($argument->is_default))) {
unset($args[$position]);
}
$position++;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.