Is there any special consideration needed to get the Category Module functioning with Forums?

I am in a good position, starting with a fresh site..
I am using Drupal RC3, no taxonomy information defined.
I installed Category from CVS [17/11/06].
I manually installed the taxonomy wrapperi module.

All fine so far.

I go for Forums, 'no Forums Defined'. Fair enough.
I go to Administer- Forums. 'No existing Containers or Forums'

Here the problems begin.
I try to add a containeri here.. doesn't show up under Administer-Forums.
Same problem with adding a Forum.

I can't see a way to structure Forums from within Administer-Category.

Am I going about this in the correct fashion?

Incidentally,
I tried to go back a step, Disabled Category Module, and went back to the original Taxonomy module, and then the Containers and Forums I had been creating [but didn't appear originally] showed up.

Regards
Alan
PS Is Drupal.org using the Category Module to show links between forum topics?
PPS I Previously posted this on Greenash, but maybe this is a more suitable place to post.

Comments

Jaza’s picture

Status: Active » Closed (fixed)
Frando’s picture

Status: Closed (fixed) » Active

Hmm,
there seems still to be some kind of bug, cause it's not working for me.

I'm using drupal4.7rc3 and latest category module from CVS HEAD.

I did the steps you explained here, but there is no new Container appearing on administer->categories.
Taxonomy wrapper is installed and it says it's installed correctly (on the settings page).
I also de- and reactivated the forum module, no change (still no forum container created).

I looked through the code in forum.module, and that's the interesting part:

 $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = '%s'", 'forum'));
    if (!$vid) {
      $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum' => 1));
      taxonomy_save_vocabulary($edit);
      $vid = $edit['vid'];
    } 

So the forum.module is expecting the 'module'-field of the forums vocabulary/container to be 'forum' ... but have no idea why there is no container 'forums' created, taxonomy wrapper should do exactly that, shouldn't it?

I also tried to create a container with category, and then modify the 'module'-field of the created row in 'vocabularies', but I still can't create new folders...

best regards,
frando

Jaza’s picture

One further tip that might help you: have a look in the 'variable' table in your DB, and see if there's a variable defined called 'forum_nav_vocabulary'. The forum module uses this variable to remember the vocabulary that it creates, and there doesn't seem to be any way to reset this, if for some reason you need to switch to a different vocabulary after first installing.

So if there's a row for that variable, delete it, and then clear your site's cache (SQL: 'TRUNCATE TABLE cache'). Also delete any forum containers / vocabularies that may have already been created. Then try following my instructions again.

alanburke’s picture

That last Tip did the trick for me Jaza.
I have the Category Module working with Forums now.
Cracking module!

Regards
Alan

Jaza’s picture

Category: bug » support
Status: Active » Fixed

TODO: document this on the category module site.

Anonymous’s picture

Status: Fixed » Closed (fixed)
sym’s picture

Version: master » 5.x-1.0
Category: support » bug
Status: Closed (fixed) » Active

Tested on a new install of drupal 5 with category from cvs drupal-5 branch and I can't get the forums to work with category.

I set up the forum in the way listed at http://category.greenash.net.au/taxonomymodules#comment-30. The forum container (on the category page) is created, but no categories are created.

On the forum admin page I get:

"There are no existing containers or forums. You may add some on the add container or add forum pages."

and nothing i do there changes it.

On the forum page (/forum) I get:

"No forums defined"

Is there anything else I can do?

lias’s picture

I second this result. The same thing happens for me with my 5.0 install. Forums are created that become containers/categories but these don't show up on the /forum page.

Crashtest’s picture

Same here. When I create a category as a child of the auto-created forum container it shows up in the forum. But this doesn't work with subcontainers...

lenart’s picture

I have the same problems as described by lsabug and Crashtest. I'm running the official release of Drupal 5 and Category (5.x-1.0).

The problem
I installed category module, category wrapper and forum. Following the instructions by jaza I did everything written in his instructions. I checked the forum_nav_vocabulary (in variables table) and it seems it is showing somewhere (i:1; which is the Forums topics created automatically by the module).

Something stinks...
Trying to make some containers/forums from administer -> forums the nodes are created but not shown anywhere. Also the forum structure cannot be generated since the containers/forums don't show up in the Patent dropdown. In the administer->content the nodes are listed but any node-type specified. Hmm..... Suspicious. When going to mysite.com/forum the message "No forum topics found" appears (something like this).

Digging deeper
Trying to see what happens if I put some categories through category.module (administer -> categories -> forums -> add category). The categories are created and shown on the mysite.com/forum page. Building of hierarchy is possible since the categories are visible in Parent dropdown. Creating a new Forum topic looks fine and the categories created in administer->categories are shown in the Forums dropdown. However the topic posts count are not display on mysite.com/forum neither are they visible if you go to a category/forum to which a node was assigned.

Categories created in administer->categories are also shown on administer->forums. I tried to create more forums from administer->forums but it still doesn't work.

I believe the problem lies in taxonomy.module (overridden by category.module's taxonomy wrapper) or it might be that the taxonomy-dependent modules are not written in a way to support taxonomy terms from outside regular tables. But since I'm still getting to know the heart of drupal I just can be completely wrong :)

This is what I found out so far. I hope someone will get this issue fixed soon and I hope my post will help others solving this problem.

lenart’s picture

I recreated the error message described in the last sentence of "Something stinks...". The error is not "No forum topics found" but "No forums defined".

dixieau’s picture

3 more of us experiencing the same dilemna on another thread here http://drupal.org/node/109938
(attempting to keep the threads cross referenced)

fossilfool’s picture

I'm having this problem also.

I noticed that if I flip back and forth between the original taxonomy.module and the version that comes with Category, I can toggle the problem on and off.

I wish there were a way to suppress Taxonomy's behavior, while we are waiting for this bug to be fixed.

Any ideas?

fossilfool’s picture

For those who are wondering when the module's author will get a chance to fix this bug, you may find the following of interest.
"Notice: I am away on vacation for all of 2007. My services are currently unavailable until further notice. Please do not contact me with requests or offers of work at this time. Sorry for any inconvenience, and I hope that you can find alternative services elsewhere."
http://www.greenash.net.au/contact

dixieau’s picture

oh buger! I wish I was experienced enough to tackle it myself along with the guestbook module.

I finally got it working a little by recreating the forum and using the wrapper to import and changing the vid (per an issue in 4.7), but it doesn't have the fuctionality of a true forum. I still can't add forum container or forum via the admin/content/forum although I can add a forum topic via node/add. I am creating the container's via category instead.

Hope this helps in the meantime (don't know what will happen to it all when we have an updated Category Mod though).

skcombs’s picture

Version: 5.x-1.0 » 4.7.x-1.0
Assigned: Unassigned » skcombs

We have successfully created a forum using Category and Drupal 4.7.1 by following jaza's instructions plus making sure the Forum container was configured properly to permit read/write comments and to allow content that is of type container and forum. The default container Forum does not have the settings you need to behave as a forum.

After enabling the Forum module, we used admin/forum to add two containers as children of the Forum container by making their parent (root of the Forum). These two containers have children that are forums. At first, we could not post to these forums; when we went to one of these forums and tried to "post a new forum topic", the node was created but didn't appear in the forums. Editing the Forum container and configuring it properly made everything work: be sure to enable read/write of comments. A category, though, cannot have a forum as a child.

We haven't yet ported to Drupal 5.0, so our experience may not help with 5.0-related issues.

Jaza’s picture

Version: 4.7.x-1.0 » 5.x-1.0
Component: Code » Wrapper modules
Assigned: skcombs » Jaza
Status: Active » Needs work

Fix in progress.

Jaza’s picture

Status: Needs work » Fixed

Fix committed to HEAD, 5.0, and 4.7 for this problem. Thanks.

fossilfool’s picture

Thanks for making progress on this, but it's not quite working for me.

I can now create containers and forums. But when I create a topic, it doesn't show up in the forum in which I created it.

fossilfool’s picture

see comment above.

Also, looking at the forum table in the mySQL database, I see that the new forum topics I've created have a 'tid' field = 0. I don't know if this is considered normal or if this should be the number of the forum in which the topic belongs. I tried changing one of the rows from 0 to 140 (a forum's node number) but it didn't work. i.e. it didn't cause that topic to appear in that forum.

fossilfool’s picture

Status: Fixed » Active

More information on Forums' current behavior:

In another test site, I can create Forum Containers, forums, and YES! topics. But, when I try to view the topic, the title of the topic isn't linked to anything. Under the replies section, there's the phrase "this topic has been moved." When I click that, it takes me to a page that says "No Forums defined."

Hope this helps,

Paul

bdragon’s picture

Assigned: Jaza » bdragon

Assigning to self, looking into this for fossilfool.

bdragon’s picture

I can duplicate your problem.

My patch at
http://drupal.org/node/115693#comment-192976

seems to work on this bug too.

sym’s picture

In reply to 116776, as this patch relates to it.

Patch applied, and it fixed the problem.

+1 and thank you :)

giorgosk’s picture

As described before
I had the forums setup up with containers and forums but the topics would not show up under the forums just by themselves

this patch worked for me

(if you do this patch manually and have the taxonomy wrappers installed (like me) can modify the taxonomy/taxonomy.module directly
- wrappers/taxonomy.module.copyme is copied over the taxonomy/taxonomy.module once the taxonomy wrappers are installed)

thanks bdragon

One more thing when you navigate to a container>forum and try to post a topic shouldn't the appropriate container>forum "category" be selected by default (it does not do it for me - any one else sees that ?)

bdragon’s picture

Yeah, I'm seeing that too.

forum_prepare() has no effect currently due to the way the wrapper works. I'm still attempting to figure out how to do this in a clean way...

giorgosk’s picture

bdragon (Sorry to bother YOU again but you seem very responsive)

Isn't there a stop/check on posting topics on containers/(forum containers)

when I post on a forum container the post is not appearing in forums (the way I see it containers can only hold forums not posts)

bdragon’s picture

Sort of.
I think what's supposed to happen is forum kicks back a validation error. This isn't happening though.

I'm still not sure why.

giorgosk’s picture

bdragon
without the category module installed trying to post on a container gives you the following warning (without letting you post that is)

"The item container1 is only a container for forums. Please select one of the forums below it."

hope it helps

bdragon’s picture

Ahh, of course. The check is done in forum_validate, which runs *before* the taxonomy wrapper.

/**
 * Implementation of hook_validate().
 *
 * Check in particular that only a "leaf" term in the associated taxonomy
 * vocabulary is selected, not a "container" term.
 */
function forum_validate($node) {
  if ($node->taxonomy) {
    // Extract the node's proper topic ID.
    $vocabulary = variable_get('forum_nav_vocabulary', '');
    $containers = variable_get('forum_containers', array());
    foreach ($node->taxonomy as $term) {
      if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
        if (in_array($term, $containers)) {
          $term = taxonomy_get_term($term);
          form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
        }
      }
    }
  }
}

If you manually make forum heavier than taxonomy in the system table, I'll bet the validation check will start working again (partially, it will be setting the error on an element that doesn't really exist, unfortunately...) (UPDATE system SET weight = 1 WHERE type = 'module' AND name = 'forum')

giorgosk’s picture

setting the weight to 1 of the forum module in the system did not do much,

should we be opening another issue by now ? (it is after all a different issue after all)

bacchus101’s picture

I am not sure where this stands. I have read everything above, applied the taxonomy patch comment work around, followed the directions given for setting up forums w/ categories and I still can not get a new topic to show up in the forum containers. Is there any progress with this or am I missing something here? I assume I am because it would seemingly be a super critical bug if it was impossible to have forums if you have the category module installed......wouldn't it?

paulj2sj’s picture

Couple issues I still am seeing with the Forums:

when posting a new forum topic from clicking on the "post forum topic" link while on a forum category page, it still does not default to the proper category.
Has this been patched/fixed? I'd even say just get rid of the "category" drop down box and just force the user to have to be under the category to which they want to post to before posting, instead of giving the dropdown box allowing them to post to any category. But I'll settle for it just defaulting to the current category!

sjh-1’s picture

A patch for this issue that was added in 1.26.2.1 seem to break insertions into the term_node table. This is because it copies in a taxononmy field, but that field doesn't have the tid member, needed for the insertion into the table.

The patch is referenced at http://drupal.org/node/115693#comment-192976 and http://drupal.org/node/116776

I have a fix for the problem at http://drupal.org/node/87669#comment-225000 Will that fix for the term_node table reopen issues with this bug? If so, it may mean updating _taxonomy_categories_into_terms to suit.

paulj2sj’s picture

sjh,

I ran your patch on the category taxonomy wrapper, but when going to post a new topic it does not default to the current forum. For example, if I'm browsing under a forum category, let's call it "TV Talk" and on I click on the "Post new forum topic" link, most users would assume their new topic would go under this category; however the "category" dropdown box on the "Post new forum topic" page does not default to "TV Talk" category, instead it just uses the top category in the box.

Was your patch even supposed to fix this?

macson_g’s picture

Can not sort out the default container issue (new thread never has proper category set by default), but managed to work around the validation issue, with cruel but efficient way, modyfying 'forum_validate' method in forum.module:

function forum_validate($node) {
  if ($node->taxonomy) {
    // Extract the node's proper topic ID.
    $vocabulary = variable_get('forum_nav_vocabulary', '');
    $containers = variable_get('forum_containers', array());
    foreach ($node->taxonomy as $term) {
      if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
        if (in_array($term, $containers)) {
          $term = taxonomy_get_term($term);
          form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
        }
      }
    }
  }
  // category version
  else if ( $node->category ) {
    $containers = variable_get('forum_containers', array());
    foreach($node->category as $category){
      if(in_array($category, $containers) ){
          $term = taxonomy_get_term($category);
          form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
        }
    }
  }
}

mr.andrey’s picture

After struggling on getting Forums and Category working on Core 5.2, I finally got it working - details below.

This seems to work on getting all the previously created forums and topics back, but make sure you back everything up first.

Problem: After installing Category module, forum disappears, and a newly added container just doesn't click with Forums.

Cause: This seems to be because the ID of the forum container is hard-coded into the database without an automatic way to change it through drupal admin interface. So if forum vocabulary/container was 1 before installing Category module, afterwards when you create a new container, unless it has the ID of 1, it will not work.

Solution:
NOTE: This is a backwards way to fix things - we'll be creating a new category and changing it to match the old configuration of the forum module. There probably is a more straight-forward way to change the old configuration to match the new container, but this is easiest for me now and it works.
One downside to this is that you will have to delete or move the node with the same ID as the old forum vocab (more on this below).

What we want to do is first determine what that ID was. This can be accomplished in two ways:
1. Create a new page with Input format of PHP, and use the code below to determine what the ID is:

<?php
$vid = _forum_get_vid();
print 'This is the result from _forum_get_vid(): ' . $vid;
$vid = variable_get('forum_nav_vocabulary', '');
print '<br>This is the result from variable_get(forum_nav_vocabulary, ): ' . $vid;
?>

see this comment for more on this: http://drupal.org/node/84180#comment-160894

2. Go to your database and look at the table `variables` for variable named `forum_nav_vocabulary`. You should see something like this: s:1:"1";

Now that we know that our forum vocab ID is 1, let's proceed:

* First, go to node/1 and delete it, for in Category module, all the containers are nodes and we're going to create a container with ID of 1

NOTE: In my case, the node ID 1 happened to be a group. The best way around this is to create a new group, then when deleting the old one, move all the group posts to the new one. You will also have to notify the members of this, so they can resubscribe.

* Now create a new container
name: Forums
types: forum_topic
required: yes
show prev/next/up links: disabled (optional)
display toc: disabled (optional)

* We need to determine the ID of this post, which can be easily gotten by moving over any of the links related to this container. Let's assume that the ID is 40

* Let's go to the database and make the following changes:
vocabulary table:
Delete the old Forums with vid 1
Change the vid to 1 (the number you get from _forum_get_vid() above)
Change the module field to "forum".

vocabulary_node_types:
Delete the old Forums with vid 1
Change the vid to 1 (the same number you edited into vocabulary table above)

In the following tables, change the cid from 40 to 1 (or whatever numbers you have):
category
category_cont (also change the `module` to "forum")
category_cont_distant
category_cont_node_types
category_display
category_hierarchy
category_views

In the following tables, change the nid from 40 to 1:
node
node_access (erase the old entry if necessary)
node_comment_statistics
node_revisions

In `url_alias` look for `src` node/40 and change it to node/1

That's it, the forum module should now work!
--------------------------------------------
Below are some other tips that you might find helpful.

> Enable Access Control on forums to work with OG Forum module
Make sure Category access control lite is installed and OG Forum Access Control is enabled.
Go to admin/user/access/cac_lite, select Forums and click Save.
Now the OG forums should show up only to the members of the group.

> Autocomplete problems with Community Tags
The following error pops up when entering data into autocomplete field
|----------------------------------------------------------------------
An HTTP error 404 occured.
http://site.com/taxonomy/autocomplete/2
----------------------------------------------------------------------|

This is due to Community Tags module looking for /taxonomy instead of /category.
Very simple fix - in community_tags/community_tags.module, look for this line:
| '#autocomplete_path' => 'taxonomy/autocomplete/'. $edit['vid'],

and replace with this:
| '#autocomplete_path' => 'category/autocomplete/'. $edit['vid'],

mr.andrey’s picture

UPDATE TO ABOVE

There are actually a few more tables that need to be updated for full integration. Here's an updated list.
If you want find these out yourself for your own database setup, which may contain other things my database doesn't, just get VIM (or another regex-compatible editor) and do a search for \D40\D, though not all the values are necessarily the ones you're looking for, so use with knowledge.

Updated list of changes to the database:
vocabulary table:
Delete the old Forums with vid 1
Change the vid from 40 to 1 (the number you get from _forum_get_vid() above)
Change the module field to "forum".

vocabulary_node_types:
Delete the old Forums with vid 1
Change the vid from 40 to 1 (the same number you edited into vocabulary table above)

In the following tables, change the cid from 40 to 1 (or whatever numbers you have):
category
category_cont (also change the `module` to "forum")
category_cont_distant
category_cont_node_types
category_display
category_hierarchy
category_menu
category_views

In the following tables, change the nid from 40 to 1:
category_menu_map
history (delete old if necessary)
node
node_access (delete old entry if necessary)
node_comment_statistics
node_counter
node_revisions

In `url_alias` look for `src` "node/40" and change it to "node/1"
Also look for "node/40/feed" and change to "node/1/feed"

In `menu` look for `path` "node/40" and change it to "node/1"

NOTE: This will not get back your old posts, look on Category documentation site for that.

rimma’s picture

Oh... Do we have another way to fix this issue?

JirkaRybka’s picture

Speaking of Category + Forum, see also this Issue: http://drupal.org/node/117172

Allowed me to use the modules together on production site.

JirkaRybka’s picture

Just for reference: Compatibility Category vs. Forum - see also http://drupal.org/node/117172 for useful patch.

liam mcdermott’s picture

Marking #193950: Not Seeing Topic List on Forum Page as duplicate of this bug.

bacchus101’s picture

Status: Active » Closed (fixed)