View that shows all terms, with or without associated nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
Screenack's picture

Using Drupal 7.8, Views 3.0

I have a node type; "Career Postings" which has an associated taxonomy "Department."

Some terms will be empty. However, I'd like to show all terms. I.e.,;

Admininstration

There are currently no positions open <-- there are no career postings associated with this term

Sales

Eastern Regional Sales Associate

Manufacturing

There are currently no positions open <-- there are no career postings associated with this term

etc.

Currently I can create a filter that only shows terms that have an associated node.

I can think of some ugly hacks, but I'm guessing there's a better way.

Thanks as always!

Comments

No Results Behavior

PeteS's picture

Hi there,

I don't think filtering is going to help you. If you were to just add the taxonomy field, and configure the "No Results Behavior" option, would that do what you want?

Best of luck,
-Pete

Huh

Screenack's picture

I'm using that taxonomy across various node types, ("staff" and "documents") so I have to filter those out.

Term View

PeteS's picture

Ah, I think I understand then. So I'm guessing that you're doing a node view? If so, then the query makes it difficult to simultaneously filter + include records that do not pass that filter.

If you are in fact working with a node view, I would recommend switching to a Taxonomy Term view. That ensures that every term gets included according to your filter (i.e. show all of the Career Posting-specific departments); then, you can create a relationship to the nodes that have those taxonomy terms ("Taxonomy term: Content with term"), and add the node fields as you would ordinarily do (making sure to set the relationship field for each of those node fields to the "node" relationship.) Then you'd set the "No Results Behavior" for, e.g., the (node) node.title field to say "There are currently no positions open."

Almost, but back where I started

Screenack's picture

Pete,

This was off to a great start. I created a term Taxonomy View for the vocabulary "Department" where the defaults show all terms; great.

Relationships

Next I added a Relationship -> "Taxonomy term: Content with term"

Fields section:

Present Field: Taxonomy Term: Name

I add the (node) Content: Title to the "Fields" section

Now the "auto preview" is showing all nodes which have the department vocabulary in their definition.

So this is where I apply a filter, if I read you correctly:

Filter Criteria

Note that creating a Taxonomy View inserts a filter, "Taxonomy Vocabulary: Machine Name (=Department)" so I'm adding a second filter:

(node) Content: Type (= Career Posting)

Right back to where I was yesterday

Here is the exported view: http://pastebin.com/9rQfRkui

Sorry, I forgot about the

PeteS's picture

Sorry, I forgot about the filter you needed for the node as well. In terms of the SQL, it would be nice to be able to do an "outer join" but I don't think Views will do that. I'll keep thinking...

any solution

pegahmajma's picture

hi,
did you find any solution for OUTER join to show all taxonomy terms with filters?

any solution

pegahmajma's picture

Hi
did you find any solution to show all taxonomy terms with exposed filter?

I think it would actually

sheena_d's picture

I think it would actually work if you go back to a "content" view, add your filter for content type as usual and add an argument ("contextual filter") for "taxonomy term" and set that to display all results if there is no argument. Then you would display the taxonomy term as a field, set the "group by" option under format settings to group by taxonomy term.

North Carolina

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: