Community Documentation

How To: Different Headers using Pathauto, Views, Taxonomy, Context, and Views Slideshow

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.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Programmers, Site administrators
Keywords
automated, context, different headers, multiple images, pathauto, taxonomy, views 3, views slideshow

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here