I have Drupal content whose nodes have URL aliases;

/node/1 routes to /bar

I also have a View which passes a NID as a contextual filter:


[selected radio] Provide default value


[selected dropdown] Raw value from URL


[selected dropdown] 1

[checked] Use path alias

View's Path is set for /foo/%


/node/1 returns node

/bar returns node

/foo/1 returns view

/foo/bar returns a white screen

How do I allow the View to access the node's URL alias as a conditional filter?

Thank you enter image description here

  • Are you using Drupal 7 or 8?
    – sonfd
    Commented Apr 23, 2018 at 20:50
  • Have you checked your error logs? Do you have error reporting to screen enabled?
    – sonfd
    Commented Apr 23, 2018 at 20:55
  • Looking at your screenshot it seems like you'll want path component #2 instead of #1
    – sonfd
    Commented Apr 24, 2018 at 1:21
  • i think your path component instead on 1 must be 2, site= 0, foo= 1, bar= 2
    – pinueve
    Commented Apr 24, 2018 at 1:29
  • sonfd, thank you, you are correct, this was my error. However, changing path component to 2 does not change behavior; /foo/[nid] still returns view /foo/[alias] returns a white screen. Commented Apr 24, 2018 at 1:30

1 Answer 1


Maybe the View Url Path Arguments module. I am seeing it recommended in this thread, but I'm really not sure if that's your issue or not.

Alternatively, you can implement hook_views_pre_view and alter the argument passed to the view based on the value in the url, i.e. do the conversion from alias to id manually. If you have an issue when your alias contains a /, an alternative may be to use a query string for the contextual argument.

  • sonfd, thank you for your reply. I'm struggling with the "Use Path Alias" checkbox, seemingly this is available out-of-the-box and I'm just failing to understand how to implement it. Drupal has long-touted friendly URLs and it does not seem that custom code should be required. Also, I reviewed the link you provided (and searched for additional writing about the hook) and I'm just not certain how I'd implement it. Thank you. Commented Apr 24, 2018 at 1:19
  • 1
    Thank you sonfd, you have helped me solve my issue. Here is the strange thing, if I create an "alias" on my content type (just a text box), populate the field, and change the change the contextual filter to field_alias, the View returns the page /foo/bar. I also checked out View URL Path Arguments; it works assuming validation criteria is provided when the filter value is in the URL. drupal.org/project/views_url_path_arguments/issues/2285223 Commented Apr 24, 2018 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.