I installed category_views module and opened a category node.

Instead of displaying nodes only from that category it shows ALL nodes. OK, I get it, we need custom views filter(s) to pick up only the right nodes belonging to that category.

This seems to be functionality that category_view module should implement through views hooks...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vatavale’s picture

I believe, it's not bug. Just need to use arguments in view query. Please, read the documentation.

Dave Cohen’s picture

FileSize
15.4 KB

The category_view module is about using views from within category nodes. Not implement views hooks. I think most people who need those use the legacy module that makes categories look like taxonomies.

I took a stab at converting the view_taxonomy.inc in views/modules to work with category. I got working just enough to do what I needed for one site. It's not pretty, but here it is for anyone who wants to try it out, work on it, or rebuild from scratch.

bejam’s picture

Can anyone point me in the direction of the docs for the settings in the views module arguments to pull a view into a category. I seem to remember you have to specify cid or something, but can't find details other than the example in jaza's tutorial which doesn't go into specifics. Some more detailed examples would be great.

dado’s picture

Ah, I see. category_views module only does this
"Allows node listings on category pages to be rendered using a view"

It would appear we need a module that permits category info to views arguments, filters, etc. Will look at the views_category.inc attachment.

dado’s picture

Category: bug » task
Status: Active » Needs work
FileSize
15.43 KB

yogadex' patch is rough but his vision and early work is on track, i think. without changing any of yogadex' code, i repackaged into a very basic module (attached). presumably this module, once finished & renamed however, would show up in the "contrib" folder for category module.

i have no time to get under the hood of this now but in case anyone was leaning in that direction...

marking this as a patch

venkat-rk’s picture

Sounds very promising.

Dave Cohen’s picture

The reason I made an .inc instead of a module is to follow suit with all the files in modules/views/modules/. I was imagining the file going there, but I'm not sure if views would include it.

Anyway, my work is _very_ rough. Rather than start from scratch, I just started editing a copy of views_taxonomy.inc. I'm sure there's code in there I haven't fixed up. I got just what I needed working and haven't had time to do it right.

But I agree this stuff is very needed for category module.

dado’s picture

yogadex
i suspect views will not want to include if possible. e.g. a recent views enabling of event module that i offered was directed to the event module. of course you could argue category is potentially more fundamental. bottom line i suspect (could be wrong) that this code will end up as a contrib add-on to category module

1 bug in your code if you point to "container" table, which does not exist

very good start though. i encourage you to keep up the good work! :}

marcoBauli’s picture

i guess this approach should fix all those Taxonomy: Term for [container] fields and filters not working on Views+Category, am i right?

+10 if that's the case :] *gone to try dado's mod*

marcoBauli’s picture

can't help from posting a positive feedback:

installed and used Field: Category: Categories for [my container]

seems to work..and both on page and block views! yikes!

marcoBauli’s picture

just a heads up:

this patch by KarenS fixes a bug in the taxonomy.wrapper that prevented categories and containers (aka Terms and Vocabularies in Views) to be properly parsed in filter and field hooks in Views.

Jaza’s picture

@yogadex, dado: +1. Great work you guys are doing here! You are quite right that category_views doesn't implement the views hooks at all: it just provides a very 'dumb' interface that lets you plonk a view inside a category's node listing. However, the view that you use for such a listing still relies on the taxonomy module's implementation of the views hooks, which are made accessible through the taxonomy wrapper.

I am all for the category module having its own native implementation of the views hooks - I just never bothered to do it myself, as I don't have that itch to scratch. For most purposes, the taxonomy module's views hooks (through the taxonomy wrapper) are more than adequate. However, for some things (such as a view with a depth >0, that is designed to traverse down through distant parent categories), they are not adequate.

I'm thinking that once this work is ready, it can be added directly into the category_views module. If that happens, then category_views will have two distinct purposes: (a) to let you embed a view within a category's node listing; (b) to implement views hooks natively for the category module, and to allow category-module-specific filtering, sorting, fields, arguments, etc in views. What do you think of that?

The other option (and I am seriously quite happy to do this, if people think that it's the right thing to do), is to add a new views_category.inc file somewhere within the category package (perhaps even in the root dir?), and to have an if (module_exist('views')) require_once('./views_category.inc');, directly in the 'core' category module. I wouldn't do this for every module, but views is a very important module, and it will probably be in Drupal core (to some extent) in the near future.

I don't like the idea of a new category_views_integration.module. This stuff belongs either in the existing category_views module, or as a file that is included by the 'core' category module. ATM, I'm leaning towards the former.

Dave Cohen’s picture

Jaza,

I like your idea of if (module_exist('views')) require_once('./views_category.inc');. That would work well for me. I can imagine however if one has views, category and taxonomy wrapper installed then one might get the impression that all the category fields appear "twice" in the views forms. (Once via taxonomy and once via category). Could confuse some. Personally I believe category should stand alone without the wrappers for taxonomy and book, but that's another topic.

While I'm staying tuned to the issue and very interested, I don't expect to spend much time on it. (Don't have the time to spend). My initial contribution was just enough to scratch my itch. I'm happy to test patches and if my itch spreads I will continue to contribute.

venkat-rk’s picture

I prefer the idea of having this rolled into category_views rather than a .inc file. Just as when you use the taxonomy wrapper module, you get only one 'categories' link in the admin menu, it will be far less confusing for users if they see just 'category' instead of both 'taxonomy' and 'category' appearing on the views building forms.

Category should be on its own and IMHO, this will move category a step closer to really replacing taxonomy in core in 4.8 or 5.0 or later.

Jaza’s picture

@Ramdak:

Just as when you use the taxonomy wrapper module, you get only one 'categories' link in the admin menu, it will be far less confusing for users if they see just 'category' instead of both 'taxonomy' and 'category' appearing on the views building forms.

Unfortunately, no matter what we do, users will always see the 'taxonomy' stuff (as well as possibly the 'category' stuff) on the views building forms, if the taxonomy wrapper is enabled. This is because the views_taxonomy.inc file is bundled with views by default, and it is used if the taxonomy module is enabled (regular or wrapper). The only way to stop this behaviour, is to instruct users that they should rename (or delete) the views_taxonomy.inc file when enabling category_views. I guess we could have another dodgy script to do this renaming, similar to the wrapper install/de-install script (which is also quite dodgy, btw :-p).

bdragon’s picture

Assigned: Unassigned » bdragon

Marking this as master bug for missing views filter capability.
Following up with list in a moment, standby.

bdragon’s picture

First run through the queue came up with these.
category_view only works on categories? (not containers?) http://drupal.org/node/85022
Category Views as tabs, Container Views http://drupal.org/node/85757
adding tabs to a view that's used with category module http://drupal.org/node/87981
Container Depth Doesn't work with Views module http://drupal.org/node/76138
Views will not refresh when adding containers and categories http://drupal.org/node/63498
Different Views for different categories within a container http://drupal.org/node/73366
Views with Category Nodes: view_data_name problem http://drupal.org/node/71685
Category module: converting a views generated page to a category? http://drupal.org/node/71039

As an aside, we are one bug short of bringing the queue down to 7 pages.

inforeto’s picture

Here's a thread with some code that could be used for a patch: http://drupal.org/node/69861
The list of argument handlers and filters must be completed first.

marcoBauli’s picture

I would add possibility to set a"Argument: Distant Children nodes" argument for outputting nodes listed under distant children categories.

This is pretty usefull when setting up drill-down activeselect menus that need distant parents / children in order to work.

(PS: i also am willing to pay anyone capable of solving this issue, since i need it pretty soon but i'm noob at php ;P if interested, please just drop me a line)

marcoBauli’s picture

Title: Category views need a new Views filter » Category + Views Integration

just tryed both the category_views_integration.module AND the code found at http://drupal.org/node/69861 but didn't find a way to select dynamically (with an argument) nodes filed under children or distant children categories. A bit more fresh this morning, what i and hopefully others need here probably is:

1. Argument: Category Hierarchy: Parent

2. Argument: Category Hierarchy: Distant Parent

both with an 'Option' field to specify the number of desired levels of hyerarchy.
Maybe it could be just one single argument (the first one) automatically parsing also distant parents if 'Option' is not 0, but maybe others might need these features separated.

Oh, yes, comments apreciated!

(changing title as this is getting bit wider topic, bdragon please revert back if you think is the case)

lias’s picture

I've just installed latest category module for drupal 5 and when I go to create a view there are no options in filter, arguments, sort that reference the taxonomies I just converted to categories, just for taxonomy and terms.

I do have category views enabled as well as views so I'm not sure what I'm supposed to be seeing. I did try selecting one of my old taxonomy/terms but nothing shows up in the block view I created since I'm guessing these have all been converted to categories and containers.

Lsabug

drurian’s picture

It looks like category_views is mostly broken at the moment. I wonder if anyone would be interested in fixing it for a bounty.

lias’s picture

superstar posted a possible fix to this problem at the bottom of this issue http://drupal.org/node/90145. I've yet to try it but it may work if you haven't already enabled other content types to be turned into containers/categories.
lsabug

liquidcms’s picture

can some one answer this for me regarding parent/child creation and views + categories

- i have 2 cck types: product and product_review
- for lack of a better idea i have made product type take on container properties and product_review take on category properties (please tell me if i dont do this).

- i would now like to attach a product_review to a product.. which i assume i could do like this:

node/add/content_review/parent/X

where is X is the nid of the product that i want to attach to

so.. after playing with combinations a while i see that if i have done container/category config as mentioned that i now see parent/child realtion in category_hierarchy table

all seems good so far EXCEPT:

- i manually need to select parent when adding review (although i think i have seen a post on auto-parent population)

- and, BIGGEST issue is that i don't see a vocab entry for this parent and therefore no way to use cat tax wrapper to use this new relational info in a view (via passing parent as arg).

Am i missing something here? Is this what this thread is about? Does this not seem like a pretty common use - i.e. relational database???

I can actually do everything i have sugegsted here with the relativity module but i thought perhaps the cat module might have be a better choise.. since i sort of thought that was one of its uses.

peter...

inforeto’s picture

- i manually need to select parent when adding review (although i think i have seen a post on auto-parent population)

- and, BIGGEST issue is that i don't see a vocab entry for this parent and therefore no way to use cat tax wrapper to use this new relational info in a view (via passing parent as arg).

For this you can open a new issue with support request. This one is for adding views handlers, i think.

For auto-population i use the active select module and also check that you have the "add child category" links on the container.
The vocab entry is the node number (container or category), try it on arguments as it work for many modules like banner and views (with the patches).

reggie75’s picture

I tried using the category_views_integration.module to expose category filters in views.
it works well.

However, here's a problem I encountered with it:

After enabling this module, I created a view using taxonomy filters (NOT category filters), and that view was not showing me any results for valid filtering criteria, when i knew data was there in the system.

I disabled this module, then recreated the view, and it started working fine.

This is to the best I observed.

Thanks,
Reggie

reggie75’s picture

I apologize. Please ignore the above issue.
The problem was due to some other settings.

The module works fine.

Thanks,
Reggie

NessTea’s picture

Project: Category » Views (for Drupal 7)
Version: master » 5.x-1.6
Assigned: bdragon » NessTea
Category: task » support
Priority: Normal » Critical
Status: Needs work » Active
FileSize
201.38 KB

Hello. My issue is very specific and demanding. I want to be able to organize my site content into categories and be able to manipulate those categories. I will use the Views module, CCKs to create custom content types, and Categories or tag content with. I will create a CCK called Test. I will then create a container called 'News and Events' and allow 'Test' pages in this container. I will then create 2 categories: 'news' and 'events' to organize the differences. I want to be able to create 'Test' pages, tag the category (if it is news or an event) and be able to display all content for each category using a View.

Everything works great, except when I want to create the View. The Views module allows me to display all categories, containers, pages, and 'Test' pages because they are all content types. I want to organize pages with categories, and display specific categories using Views.

So I have my category system set up like this (example):

  • News and Events - Container
    • News - Category
    • Events - Category

The Views module allows me dynamically view Containers and/or Categories, but not specific categories. So if I filter 'Node: Type' and select 'News and Events', it will only display all those News and Events nodes. I want to view all the News OR Events based on categories. I can only select 'Categories' and 'Containers' from the 'Node: Type' list.

Reason I want it done like this is to allow larger sites to take advantage of the category system and be dynamically correct. I want to specify multiple categories and view any part that I request.

Any help? I can provide screenshots if needed.

merlinofchaos’s picture

Project: Views (for Drupal 7) » Category
Version: 5.x-1.6 » master
Category: support » task
Priority: Critical » Normal
Status: Active » Needs work

NEVER take over old issues and completely recategorize them.

bdragon’s picture

Assigned: NessTea » bdragon
fluitfries’s picture

I've updated to latest modules and core 5.2 and I'm still unable to get this working. I've followed the directions to a T from the documentation. It seems like the Container is not understanding how to pass the Taxonomy: Term ID argument to the view. But I'm no coder, so don't take my word for it.

The symptoms for me are that it does not display any view at all in the container. The container simply acts as if a view was never specified. If anyone can verify that this symptom is not related to the bugs and is instead user error, please point this out to me!

I think this particular issue is an oft used feature, so I hope it gets fixed!

Thanks and keep up the good work.
-Kingnoc

PGiro’s picture

subscribe

grzegorz@paniw.eu’s picture

So, i have problem with tabel term_node and category_node.
In category_node we have id node and id category. Table term_node should by this same... but doesn't! In term_node all nodes are in category id 1.

Mayby someone could telm me where (in code) is bug?

/sorry for my english.../

grzegorz@paniw.eu’s picture

Ok, problem is on line 575 in file taxonomy_module (taxonomy.module.copyme).
Is:
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term);
Must be:
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term->cid);

I hope, that i don't make some bug ;)

inforeto’s picture

read the master thread: http://drupal.org/node/87669
check the patches there for the various modifications.

esmailzadeh’s picture

in use views with category this must be regarded:
1-use category_view contrib ver 5.x-1.x-dev instead of category_view ver 5.1
2-when we add a argument (term id) in title field must fill: "%1"
if we dont fill this text in title field of argument nothing can nor be show
i think most people dont fill this field and meet these measures.

this work well for me

esmailzadeh’s picture

i have a mistake this is not work all thing was going wrong still and i will switch to taxonomy way and i will use taxonomy via panels

Jax’s picture

FileSize
2.83 KB

New views files against HEAD for 6.x. Work in progress, feedback welcome.

fizk’s picture

Jax, thanks for the patch, it works well.

I'm trying to list my categories like craigslist, where the heading for each section is a container. How can I do this?

Jax’s picture

Fizk, that is a separate support question, you should not hijack an issue thread with an unrelated subject. You should open a new issue for this. You also should provide a link or an image that describes your problem since not everyone knows what craigslist looks like.

webevt’s picture

Assigned: bdragon » webevt
Category: task » support
Status: Needs work » Needs review

Jax, thanks for the patch, but I can't make it work.. I've successfully applied it and got a file category.views.inc. What should I do with it? I tried to copy it to the ./modules/category/contrib/category_views, but it make no changes - there is no Category filter in the Views module..

Sorry for my english

inforeto’s picture

Assigned: webevt » Unassigned
Category: support » task
Status: Needs review » Needs work

@webevt:
Try placing the category.views.inc on the same directory as category.module.

webevt’s picture

inforeto, thanks a lot! I copied category.views.inc to the ./modules/category/ and now it works well! =)