Hello,
I needed to create a tag cloud to display on a userpage that would only display the tags /that/ user has used (as opposed to ALL the tags on the site). The attached patch will add this functionality without breaking existing functionality.
I actually placed it on my userpage by modifying the snippet I found here:
http://drupal.org/node/157802
to this:
<?php
$tagcloud = "";
drupal_set_html_head('<style type="text/css">@import url('.drupal_get_path('module','tagadelic').'/tagadelic.css);</style>');
$vocs= array(4,5,410); // ids of vocabs for which you want to build a tag cloud
$tagcloud = theme('tagadelic_weighted',tagadelic_sort_tags(tagadelic_get_weighted_tags($vocs, 6, 60, $uid)));
print $tagcloud;
?>
Notice that 6 and 60 in tagadelic_get_weighted_tags() are simply the defaults, and $uid should mean something (if you are using a different variable on your userpage for user id (like arg(1) or something), use that instead.
| Comment | File | Size | Author |
|---|---|---|---|
| tagadelic_13.patch | 1.7 KB | entendu |
Comments
Comment #1
Bèr Kessels commentedIt is really easy to do a Db_query and pass that trough the APIs of tagadelic.
Having such arguments as $userspecific (code style says $user_specific, for one) is not a good idea. What is next? $christmas_only? or $in_types = array()?
Please read up on how to use the api and you can wirte a less then 20-lines module that gets/builds user_specific clouds.
Comment #2
mariusooms commentedUsing the following code I'm setting the uid to the current user:
So I end up with the following in a block:
Note $user->uid in tagadelic_get_weighted_tags.
Bèr, the forum is loaded with request for user specific clouds, yet no-one has offered a good (or any other) solution. So if you are able to write a 20-lines less module that gets/builds user_specific clouds, the community would be forever grateful. For now...this patch gets the job done.
Kind regards,
Marius
Comment #3
Lausch commentedMr. Kessels,
i agree with you. This code break the Drupal coding standard but its the only solution i ever see.
i shake my hands with mariusooms. so i will be happy too to see this "> 20 lines module"
regards
Lausch
Comment #4
Lausch commentedok i found a solution that works for me with the community tags module
i want to see my tagcloud in a block so i added a block with the following php code:
regards
Lausch
Comment #5
mariusooms commentedA great solution. Also it now allows to combines ajax user tagging on the fly. Great idea Lausch!
Regards,
Marius
Comment #6
Bèr Kessels commentedPlease refer to http://drupal.org/node/253514 for this and other such requests.