I'll try to explain my problem as best I can.

I'm building a corporate site with Drupal 7.4. This site must have a section that shows all the jobs and projects developed by the company.

To reach this goal I created a new content type called Project. The Project content type has several fields to save the information for each project. To classify the projects I created two vocabularies ("type", for the type of project, and "location" for the project's location). Then, I added two taxonomy term fields to the Project content type for each of these vocabularies.

To build the pages with the information of the projects I use Views 3.0-rc1. As I mentioned before, the site must have a section displaying the projects developed. I created a view including several fields of the Project content type. I put some of these fields as exposed filters to the user is able to filter projects according to various criteria.

So far there was no problem. But I also need to create a Views page to filter projects by his "type" and "location" taxonomy terms. To do this I use the contextual filters so that the "projects/type/location" path must display projects that correspond to the type and location indicated in the URL. I tried to create two taxonomy term contextual filters but I read that in Views 3.0-rc1 I have to create a taxonomy term relationship in order to use the taxonomy term contextual filters.

Then, I created a "Taxonomy term: Content with term" relationship including the vocabularies "type" and "location". I also created two "Taxonomy term: Name" contextual filters for each of these vocabularies using taxonomy name validation criteria. I thought that this would work fine but I tested the view with two contextual filters and it returned no results.

I managed to get do this view with the beta3 subversion of Views 3.0 and it worked correctly because in that version there was no need to create any relationship to do this view...

What types of relationships and contextual filters should I use? Do I have to create a relationship for each contextual filter? Or just a relationship for both?

Thank you very much again for your help!!


theresonant’s picture

Have you tried using Arguments? That would be my first thought. I would create a View with a Page display at the URL "projects", and add two arguments of type "Taxonomy: Term". The arguments of a View are given via the URL, so you can use "projects/industrial/valencia" to select all the industrial projects that take place in Valencia. I don't remember exactly how you use the arguments, sorry for that, but I'm suspecting it's in combination with the Filters. If this is the answer to your question, read the documentation of Views Arguments and find out how to use them.

I've given this answer mainly based on you saying
"But I also need to create a Views page to filter projects by his "type" and "location" taxonomy terms."

I hope I understood your question properly.

Good luck!

ajFernandez’s picture

First, thanks for your quick reply. You understood my question perfectly :)

As you mentioned in your response, I referred to Arguments in my post. I'm using Arguments in order to do this view display. I said "Contextual Filters" because in the new version of Views (Views 3.0-rc1), Arguments are called "Contextual Filters".

In short, my idea is to do this view the way you said, that is, using arguments.

However, my problem is that in this version of Views I don't find the argument of type "Taxonomy: Term" in the Arguments list. I read about this and I found a post that said that to create an argument of this type is necessary a relationship (or more?). So I created a "Content: Taxonomy terms on node" relationship but I am not sure that the relationship has to be like that.
Then, several new items appeared in the Arguments list. I already could create an argument of type "Taxonomy: Term" so I created two arguments of this type, but the view doesn't return the expected results. More specifically, the view returns no results.

I don't know if the problem is due to type of relationship(s) or arguments, or if it due to configuration of them. Do you help me?

Thank you very much for your help!!


mikeg333’s picture

You are correct about having to add the relationship to then get the contextual filters for the taxonomy term. For the contextual filters you add make sure the options for when filter is not available is set if one of the terms isn't present. If this is set to show no results if one of them validates but the other doesn't you will get no results. Also I found that the only way I could get results was to have the contextual filter be Term ID then check the box to validate it and have it do a term name to term id conversion with dashes converted to spaces.

ajFernandez’s picture

Hi mikeg333,

thanks for your response. Do I have to create one relationship for each contextual filter? Or I have to create only one relationship for all taxonomy contextual filters?

Thank you very much again.


ajFernandez’s picture


anyone have any idea??


jcamfield’s picture

I have the inverse problem - I have content with multiple taxonomies, and in Views, I want a Contextual Filter to give me a simple list of content-by-term (with other viewscandy tools, or I'd just use the taxonomy list). It kinda works, but all taxonomy terms are summed up, regardless of relationships, selecting only the desired vocabulary, and reducing duplicates. I'm on the verge of jumping ship back to D6 and giving up all the D7 goodness here.

knalstaaf’s picture

Did you hit onto the solution by now, jcamfield? I'm having a similar issue.

If so, would you be so kind to provide the answer / export of the View?

kip stanning’s picture

i think i understand your problem:
go to the section SPECIFY VALIDATION CRITERIA and select content. you get the option to specify nodetypes. this helped in my case.

regards from vienna forest

marcopanichi’s picture

use this:

$view = views_get_view('view_machine_name');
$display = $view->execute_display('display_machine_name');
if( $display['content']!='' )
	echo "


"; }