Hi

I'm using the Category module for a site and i would like to display tag clouds throughout the site.

I recently discovered that Tagadelic isn't compatible with Category.

(see here http://drupal.org/node/116540)

I'm going to post this to the issue trackers for both products as i don't know where the issue lies.

Is there any way we can get the two to work together? The category module aims to keep working with modules that need Taxonomy - but this one doesn't work.

Anyone have any pointers or willing to look into this?

Thanks

Ben

(see http://drupal.org/node/119937 for the issue on Tagadelic's tracker)

CommentFileSizeAuthor
#8 term_path.patch1.07 KBbdragon

Comments

bdragon’s picture

In the taxonomy wrapper, add a bit to taxonomy_term_path.

I have only tested this on a site with no legacy vocabularies, I don't know what happens if you attempt to use tagadelic on legacy vocabs.

YMMV, but it works for me. After I have fully analyzed this, I will commit a bugfix.

function taxonomy_term_path($term) {
  // @@@ Hack to get manually constructed terms to work.
  // @@@ (for Tagadelic)
  // @@@ What happens for legacy vocabs?
  if (isset($term->vid) && isset($term->tid)) {
    $term->cid = $term->tid;
    $term->cnid = $term->vid;
  }
  return category_category_path($term);
}
smoothify’s picture

Thanks for this, now at least it doesn't come up with the Page not found any more.

I am having problems with the free tagging though with tagadelic - its not recording the legacy taxonomy info in the database correctly.

If you post an entry with a collection of tags, new ones often get added twice to terms_data, and then get an invalid tid in terms_node

Obviously this makes tagadelic unable to display them in the cloud.

I presume this is problems with the wrapper. ( i did apply your fix)

Thanks

Ben

smoothify’s picture

Status: Active » Needs review

i've been looking at this today and think i found the problem with the free tagging.

Its in the taxonomy_save_term function, around line 337.

I added the following lines above the Insert routine:


    if (variable_get('taxonomy_maintain_db', 1)) {
       // Fix for free tagging to be recorded in legacy database
       $edit['tid'] = db_next_id('{term_data}_tid');
       $curr_tid =  $edit['tid'];
       // End of Fix
       db_query("INSERT INTO {term_data} (tid, name, description, vid, weight) VALUES (%d, '%s', '%s', %d, %d)", $edit['tid'],   $edit['name'], $edit['description'], $edit['vid'], $edit['weight']);

Before the $edit['tid'] wasn't being set at all resulting in insert errors, or incorrect id's.

Sorry i don't have time for a patch, but this is now working for me.

robby1066’s picture

I was just digging around in the tax wrapper and tagadelic modules to see if I could come up with a quick hack to make tag clouds work, and I realized that in the taxonomy wrapper, the function 'taxonomy_get_vocabulary' returns an array, whereas the original 'taxonomy_get_vocabulary' returns an object (at least in 4.7). That appears to be at least one part of the breakage on tag clouds.

that seems like that might be a high-impact change, so I haven't persued it much further, but maybe that helps someone else.

tkgafs’s picture

I have tried applying the two fixes in this mentioned in this issue

but now when I create a blog posting and add free categories to it I get errors similar to the following

* user warning: Duplicate entry '1-29' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (29, 1) in /srv/www/htdocs/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry '1-29' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (29, 1) in /srv/www/htdocs/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry '1-29' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (29, 1) in /srv/www/htdocs/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry '1-29' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (29, 1) in /srv/www/htdocs/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry '1-29' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (29, 1) in /srv/www/htdocs/includes/database.mysql.inc on line 172.

there seems to be one error for each tag minus one [ie if there are 6 tags there are five errors]

I have tried using both the current dev and the head version of category both versions do the same thing

Tkgafs

sjh-1’s picture

This issues looks to me like the one I've been looking at in http://drupal.org/node/87669#comment-225000 There the taxonomy field is populated from the category field by a direct copy, but in doing so doesn't get the tid member. Consequently, all the tid values in term_node also get value 1.

bdragon’s picture

Agree with your diagnosis.
Testing this specific issue now.

bdragon’s picture

StatusFileSize
new1.07 KB

OK, in addition to the previous patch, there is a bug in taxonomy_term_path.

This patch should take care of that.

bdragon’s picture

The path issue goes deeper than that, actually..
Modules are given a chance to override their term's path by implementing the term_path hook. Category has the same hook for categories, only it's category_path.

I think I'm going to invoke category_path and then term_path if category_path fails...

bdragon’s picture

Status: Needs review » Active

Applied something similar to HEAD, DRUPAL-4-7, and DRUPAL-5 as part of a fix I committed a few minutes ago.

Things should be working better now, please re-test with a fresh wrapper.

mlncn’s picture

bdragon, by "Applied something similar to HEAD, DRUPAL-4-7, and DRUPAL-5 as part of a fix I committed a few minutes ago" do you mean your application of http://drupal.org/node/87669#comment-225000 or is there something more?

Dealing with this issue where all tags in the tag cloud point to node!

~ ben, Agaric Design Collective

mlncn’s picture

Update? I reopened http://drupal.org/node/119937 but I realize I should have stayed over here.

mlncn’s picture

So one thing Category is doing wrong is returning an array structure in its replacement for the function taxonomy_get_vocabulary (taxonomy.module.COPYME). It should instead return an object.

Which is exactly what robby1066 said two months ago, I just realize!

I will try to find or file the proper issue to go with this, as we are operating from the latest dev release of the Category module.

- ben :: http://AgaricDesign.com

mlncn’s picture

We weren't using the latest Category dev (the April 8 one), apparently. The Agaric Design Collective has been broken up. Would anyone like a used collective member?

Tags in current post still isn't working, but everything else is.

bdragon’s picture

"Huh?"

I think part of the "node/" problem is taxonomy_term_path. It isn't actually coping with being passed *terms*.

I swear I have a patch lying around somewhere...

dacc’s picture

For awhile our Drupal 5x Tagadelic module was working perfectly. However, my client brought to my attention yesterday the following errors when she tried to add the term "anthropology" using free tagging.

* user warning: Duplicate entry '60' for key 1 query: INSERT INTO term_data (tid, name, description, vid, weight) VALUES (60, 'anthropology', '', 4, 0) in /usr/www/users/holdford/bas/prod/includes/database.mysql.inc on line 174.

* user warning: Duplicate entry '60' for key 1 query: INSERT INTO xmlsitemap_term (tid, pid, last_changed, priority_override) VALUES (60, NULL, 1241713385, NULL) in /usr/www/users/holdford/bas/prod/includes/database.mysql.inc on line 174.

Instead of adding the word "anthropology" to the node tags, Drupal adds the word "bear," which I believe is a random word from the list. (It's different every time.)

We have followed the suggested fixes described in this thread so far to no avail.

There does not seem to be a problem with our Category module, but this thread is the closest I could find to the error I was receiving.

Any help would be much appreciated.

Des

JirkaRybka’s picture

Closing duplicates:
#75025: Category module doesn't work with tagadelic (with a bit of old discussion)
#137212: Can anybody help me? (hardly even related)

Some bugs encountered in above discussion have own issues:
#338846: Taxonomy Wrapper 1.26.2.2: taxonomy_get_vocabulary as object instead of array? (array vs. object)
#87669: [MASTER] term_node tid getting set to "1" (tid=1)

We need to examine the rest here, and most probably move this to 6.x queue, but I don't use Tagadelic myself (this my post is just clean-up).