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
Comment | File | Size | Author |
---|---|---|---|
#2 | contextual_filter_raw_url_with_alias-1479322-1.patch | 1.31 KB | jadawin |
contextual_filter_raw_url_with_alias.patch | 1.11 KB | jadawin | |
Comments
Comment #2
jadawin CreditAttribution: jadawin commentedOk, I wasn't expecting the attached file to be applied automatically. Nevertheless here's a new file which should now work.
Best regards.
Comment #3
jadawin CreditAttribution: jadawin commentedComment #5
dawehnerLet's use
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.
Comment #7
jadawin CreditAttribution: jadawin commentedHi 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.
Comment #8
MustangGB CreditAttribution: MustangGB commented