1

I have a lot of views that need a content type filter which I should select about 20 content types for each of them. Is there any module to categorize content types(not contents)? For example adding a taxonomy term named news to content types news, image news,.. so instead of selecting content types I will add the filter content typs has tag news.

2

This module appears to be built exactly for your use case: https://drupal.org/project/content_type_groups

From the readme.txt: "Create a content type group called 'Media' and add the 'book', 'movie', and 'audio' types. You have just created a logical grouping between the content types to show that they are somehow related. ... Now that you have your content type group, you can filter Views by the Media content type group instead of selecting each content type individually."

I haven't used it. I was looking into coding a views filter handler etc., then it occured to me to search for "content type groups" and found this.

  • Cool - since this has integration with views, it seems to fit the bill. Crazy how you can just search for things like 'content type groups' these days and a module will pop right up!! – Boriana Ditcheva Aug 14 '13 at 0:27
  • It is cool, assuming that the module actually works. It also goes to show how crucial the module name is. And the search tearms. And of course the description of the problem, the most important thing of all. :) – Kari Kääriäinen Aug 14 '13 at 6:18
3

You can't add fields to the content type in regular old Drupal.

Also, the thing is that the view itself is pulling fields from the actual entities you're trying to list, so even if you manage to somehow add tags/fields that relate to the content type (through a custom or contrib module), your views wouldn't be able to just access those special fields by default. After all, your views are actually pulling entities themselves and accessing their fields. You know?

The simplest way to do this, I think, is to hard-code which content types you want listed in your views as filters:

In your views' 'Filter Criteria' section, simply add the filter 'Content: Type' and select all the content types to include. So, if you wanted a view that applies to 'news' category types, just filter to include all those content types (news, image news, etc). Of course, if you ever add a new content type or want to change your categorization, you'd have to edit your views by hand to match the new way of doing things...

The above is better, in my opinion, then adding a 'content category' vocabulary that is included in each of your content types as a field. Even if a 'category' vocabulary has a default, which allows content editors to create nodes and not have to set a category, the problem is that tagging each node (versus filtering by the content types as above), would make 'switching' your categories or removing/adding categories to your content types harder. If you decide to change them later, what do you do about all the nodes you've created in the meantime that have been tagged a certain way already? :-)

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.