Last updated March 13, 2012. Created by ccoppen on February 17, 2011.
Edited by danjuls. Log in to edit this page.

Problem: I needed different pages/areas of the site I'm currently developing to display different areas, as well as display a default area. But it needed to be more automated.

Pathauto and Taxonomy don't play well together in Views and so this was part of the problem.

Solution:

Requires Views Slideshow and I'm using Views 3 alpha as well, but I don't know if that matters.

Create a Vocabulary (mine's called Rotating Headers), attach it to the Image content type. Create some nodes, ensuring that they are named differently with pathauto. Upload some Images, tagging them with the same name as that of the path that you want it associated with.

ex: If the path shows "some-path," then the tag would be "some-path."

That's the easy part.

Go into views and create a new node view.
Create a new block.
Filters: Node: published, Node Type: Image, Taxonomy: Vocabulary = Rotating Headers.

Fields: Image: image

Use pager: all items

Style: Slideshow using Views Cycle.

Here's the tricky part.
Arguments:
Taxonomy: Term
Provide Default Argument -> PHP Code
Insert the following:

<?php
$arg
= explode('/',drupal_get_path_alias($_GET['q']));
$vid = 9;
foreach (
$arg as $thearg){
    
$term = taxonomy_get_term_by_name($thearg);
    
firep($term);
     if(
$term[0]->vid == $vid){
         
$terms[] = $term[0]->name;
     }
}
if(
$terms){
     return
end($terms);
}else{
     return
"front page";
}
?>

Update argument.
Save view.
Go to Context, add a new context.
Under Conditions:
Path -> *
Reactions:
Blocks-> add it to the region you want it to appear in.

You can either have multiple images per tag or not. It doesn't matter. If you do, you'll have a slideshow.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Note that, for me at least, this does not work in Drupal 7. I tried it without the "< php" as D7 suggested, but this did not work. Interesting idea though.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com