Here is my issue. Which is similar to Scott Edmond's question here Context Filter with Path Alias in URL

Scenario: I am trying to create a page view that will display content by Content:Title which is part of the node's url.

I have 3 content-types : "Movies" "Books" & "TV Shows" Each Content-type has URL Alias of [node:content-type:machine-name]/[node:title]/[current-date:custom:Ymd]

I successfully created a view called movies with a filter on content-type movies that displays all Movie posts with www.example.com/movies/ in the url

E.G. if I make a post called "Star Trek is Great" with the Content Type of Movies, I get the url www.example.com/movies/star-trek-great/20130713

If I click on the post in the Movies view, it displays the content on a node.tpl.php page

I added a Contextual Filter called "Content:Title" using Scott Edmonds suggestion: Contextual Filter for: Content: Title ). When filter is not in URL -> Provide Default Value -> Raw Value from URL -> Path Component=2. Use Path Alias=Checked. Then, When Filter Value is In URL: Specify Validation Criteria= "PHP Code" with the following PHP code: $handler->argument = str_replace("-"," ",$argument); return true; That did the trick. the PHP code converts the dashes to spaces so it can be evaluated correctly. –

saved the View and Cleared Cache

The result is that when I click on the "Star Trek is Great" post link I am taken to the correct url "www.example.com/movies/star-trek-great/20130702" but the node.tpl.php page is the template that gets displayed instead of my views-view--movies.tpl.php template

When I copy the title and paste it into the url, as "www.example.com/movies/Star Trek is Great/20130712" the views template page comes us.

Some where along the way I am missing something. Any help out there?

FYI - I also have simply set the contextual filter on Content:Title with Display all results for the specified field Checked "Override title" and added %1 as the first argument Seleced "lowercase" for the Case PATH Selected "transform spaces to dashes in url"

But nothing worked :(


The issue is the following:

When you go to www.example.com/movies/star-trek-great/20130702 Drupal sees that this is a path alias to node/#, and it displays that node. It won't use Views at all.

When you go to www.example.com/movies/Star Trek is Great/20130712, this does not map to any URL, but rather to the View sitting at www.example.com/movies with an contextual filter of Star Trek is Great (and 20130712 most probably).

You may have some other issues to work out as well:

Pathauto is taking out the is (and other small words by default) so there will be a bit of a hard time mapping star-trek-great to Star Trek is Great.

Also, what happens if you have a title of Star Trek is Great!!! that maps to star-trek-great as well?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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