0

I've created a view using a taxonomy term let's say (a,b,c,d,e)

A content type can have multiple selections of these taxonomy term.

The view returns the content-type based off the taxonomy term selected "Content: Has taxonomy term (exposed)"

From this, it also returns a select list of all the taxonomy terms.

Now in the taxonomy I have a custom field "hide from public". Terms "d" and "e" in the above list have this selected.

I would like to add a condition so that the view only returns the content type where "hide from public" is "false" and then the select list only shows the values where "hide from public" is false.

I can't add the condition if "hide from public" is false in the "Filter Criteria" because I believe it's checking for the Content-Type to have this value which it does not, so it returns nothing. How do I make the taxonomy list conditional?

Thanks!

0

The reason why you can't add a Filter based on a Taxonomy field is because you're building a Content type views and that information simply isn't available directly from content tables in the database. If you were using Taxonomy term views then you could add that filter directly.

But since you have an entity reference from your Content to the Taxonomy term, it is possible to add that extra information into Content Views, so you will be able to Filter your Content based on a Taxonomy term Field that is on the taxonomy term that your nodes are referencing.

With Relationships in Views you're allowing Views to reach into other database tables and use data from them, if they are somehow related to the entities the view is based on.

Here's how you do it in your case:

  1. Add a Relationship to the field in your content that is referencing your relevant Taxonomy Taxonomy term referenced from field_mytermref

    If you Require it, it will filter out only the nodes where that field isn't empty.

  2. Add a Filter hide from public.

    It will now be available in your Add Filter list because you added the Relationship in the above step, and that Relationship will be selected by default.

    Adjust the Operator and Value so that it's not equal to Hide from public, or the other combination that it's equal to it being False.

    Now your results will only show the nodes tagged with terms that are "public".

  3. To adjust the Exposed filter the easiest is to use the Limit list to selected items option in its settings, and select only the terms you want to appear (Use the Ctrl key).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.