It came to my notice that when using a Raw Url default value for a contextual filter that Views will use the internal path (in my case node/x) instead of being able to extract a path component from the path alias I'm using. I would like to ask for this feature to be implemented for future versions.

I hacked plugins/views_plugin_argument_default_raw.inc, added a checkbox option to allow me to choose If I wanted to use the path alias and if the option is set i pass the return value of calling drupal_get_path_alias() as an argument to arg(). I could have created a different plugin but this way the contextual filter Global:Null also works. My changes are in the attached patch file so you can look at it.

I would like, if possible, to get some feedback if this might break something within Views, cause performance problems or if there might be a better approach for achieving this. If all is well, please consider adding this to future versions.

Best regards

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, contextual_filter_raw_url_with_alias.patch, failed testing.

jadawin’s picture

Ok, I wasn't expecting the attached file to be applied automatically. Nevertheless here's a new file which should now work.

Best regards.

jadawin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, contextual_filter_raw_url_with_alias-1479322-1.patch, failed testing.

dawehner’s picture

Version: 7.x-3.3 » 6.x-3.x-dev
Status: Needs work » Patch (to be ported)

+    $options['use_alias'] = array('default' => '');

Let's use

$options['use_alias'] = array('default' => FALSE, 'bool' => TRUE);

so it's exported a bit better. Just changed it and committed it to 7.x-3.x Thanks!

This patch allows to let people do more without php eval, though i would actually recommend to write proper plugins to get the value.
Path aliases might change over time etc.

jadawin’s picture

Hi dereine, thanks for your code review and for adding this to Views. I'm sorry if there are better ways of achieving the same result but I'm only about a week or so into drupal so I still spend most of my time trying to figure things out and for my limited knowledge this seemed like good approach to avoid code duplication.

MustangGB’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (won't fix)