Drupal - Drupal 7 Contextual Filter on URL Alias
I think the simpliest way is to use Panels, and override the Node page. Add a variant and put your view in it, and send the node's nid argument to it, using node:nid contextual argument.
- (install page manager)
- Enable node view page (node/%node)
- Add a variant, set a validation criteria selecting your concerned node type
- Use simple one-column display
- Add your view in your column
- It asks for an argument, send the node:nid, (or entity_id, or whatever)
- In your view, use node:nid contextual filter
All is done.
Set path alias for the content type to something like articles/[node:title]
Option 1: using views to run detail pages
In views:
- Create a
Page
view with the path set to the/articles/%
Add Contextual filters Content: Nid and set it to the following:
- When the filter value is NOT in the URL => Provide default value
- Type => Raw value from URL
- Path => Component 1 (Check "use path alias")
This does a path lookup on the last url segment (something like "my-article-title-path-alias") and returns the correct node ID.
Option 2: By-pass views to run detail pages
Instead of setting the path as /articles/%
simply set it as /articles
and let the all the path aliased /articles/%
nodes resolve normally.