Created
February 20, 2012 15:01
-
-
Save balintbrews/1869579 to your computer and use it in GitHub Desktop.
http://drupal.org/node/1444474#comment-5626610 - backport for Views 3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment