I'm trying to wrap my head around contextual filters again! I used it a while back but I just got totally stumped again. Here's what I'm trying to do:
- Generate a cloned content node page with taxonomy terms inserted into this cloned page.
When a user reaches the /white-shoes page it will show the original node page geared toward the white color. Now if the user lands on /white-shoes/blue it will show the same node page, but this time all of the body content will be rewritten replacing the white color with blue color.
In Views I would have to create a Page display with the path of: %/%
Now I would create a contextual filter to retrieve the nid. I add Content: nid as a contextual filter. I pick PROVIDE A DEFAULT VALUE and I put in this PHP code:
$x = drupal_lookup_path('source', arg(0));
$y = explode('/', $x);
That PHP code basically converts the /white-shoes part of the URL into a NID. But it doesnt work. I tested the code via drush ev via the terminal and I indeed get a returned result, so i know it works.
I do the same for the taxonomy term name and add a contextual filter for that aswell. This time I pick PROVIDE A DEFAULT VALUE and select RAW VALUE FROM URL and select the 2nd argument.
As you can see when I input a PREVIEW VALUE for the contextual filter: AAA/BBB/CCC . My default value gets ignored. It's supposed to be grabbing the 2nd argument, but it's getting the 1st only. Look at the SQL statement WHERE and you'll see it's getting AAA when it should be BBB.
So the question is what am I doing wrong or is there a better solution to what I want to accomplish?