I have added a taxonomy vocabulary (applicable to both content types of pages and stories) called "general category" and for this vocabulary I have added a parent category called "Home" and sub categories under the "Home" category based on how I want to categorise content on my site (which incidental for pages currently matches the primary links of the site). Then I assigned a "general category" to all pages and stories.

With the Views module I have a block displaying all the stories on all pages but what I really would like is to only show the stories on pages where the category of the story and the page are the same (the home page should include all descendant categories as well). Is this possible using the standard Views module? I played around with the relationships and filter options but without success (I am a Drupal newbie).

Any assistance would be very much appreciated. Thank you.

Comments

mshepherd’s picture

Rather than relationships, I think it's Views Arguments that you need to look at.
Take a look at some of the recipes on http://drupal.org/node/70145 for some inspiration.

AndyHiggins’s picture

Thanks for the heads up with this Mr Shepherd. After studying Views more I was able to achieve this using arguments.

Arguments -> Taxonomy: Term ID -> Provide default argument

And providing argument type of php code as follows:

if ($node = menu_get_object()) {
  //To handle multiple possible taxonomia set on a node create a plus seperated list
  foreach ($node->taxonomy as $i){
    $taxonomia = "$taxonomia" . "+" . $i->tid;
  }
//Remove the first plus
$taxonomia = ltrim($taxonomia, "+");

//If Home category (tid = 1) then return NULL to display everything
if ($taxonomia == 1) return NULL;
else return $taxonomia;
}
return NULL;
mshepherd’s picture

Apart from views, you could also use a custom module, as is outlined here: http://www.kobashicomputing.com/create-a-related-article-list-in-drupal

I've used that approach before & it worked well.

AndyHiggins’s picture

Thank you for pointing me in the right direction. I will read up further on the Views documentation and if I still cannot come right I will look at the alternative method.