| Project: | Refine by taxonomy |
| Version: | master |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I saw that the writer of this module had thought about including tagadelic intergration, but that it hadnt yet been implemented. So, I had a look, and tried to do it myself... I'm afraid I dont understand how to show you how to do this by cvs, so I thought I'd post it as a feature request instead (the patch still needs work, but it works for me!)
Firstly, tagadelic doesnt allow you to create a tag cloud for certian terms of a function - you can only show the clouds for a whole (or multple) vocabularys. To fix that, you'll need to patch tagadelic (see? I told you this needed work!). To do that, open tagadelic.module and find the line starting 'function tagadelic_get_weighted_tags...' (line 180) Replace it, and the following 6 lines with the following instead:
function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60, $tids = array()) {
if (!is_array($vids) || count($vids) == 0) {
return array();
}
// Fetch tags
if ($tids == array()){
$sql = '';
}else{
$sql = 'AND d.tid IN ('.implode($tids,',').')';
}
$result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') '.$sql.' GROUP BY d.tid, d.name ORDER BY count DESC', $vids, 0, $size);This restricts the terms that tagadelic uses when it creates its tag cloud to the tags who's ids are send in the array $tids.
Next, you'll need to patch the refine_by_taxo.module file. Open it and go to line 127 ('function refine_by_taxo_build_body...') You'll see that there is a place holder for tagadelic intergration. Immediately after this placeholder, add the following:
if (module_exist('tagadelic')){
$tids = array();
$vids = array();
foreach($terms as $term){
$tids[] = $term->tid;
if (!in_array($term->vid)) $vids[] = $term->vid;
}
if (count($tids) != 0 && count($vids != 0)) return theme('tagadelic_weighted', tagadelic_get_weighted_tags($vids,4,60,$tids));
}This bit organises the data into a form understood by tagadelic (i.e. an array of vids and tids), and if at least one tid and vid is found, returns a themed tagadeil tag cloud. If, for any reason, this doesnt work, the normal refine_by_taxo list is used.
Bits that need work:
- There's no way to switch tagadelic intergration on or off - if you stick this patch in, tagadelic gets used.
- Its not been extensively tested (see here for my implementation of this patch)
- It means you have to patch tagadelic, which isnt very elegant... (i've emailed the tagadelic auther to suggest implementing this patch in future versions of tagadelic)
Comments
#1
I just realised that I should point out that although I've classed this as 'code needs work', it does work fine for me, and I've got it running on my site with no problems. If you do hit problems running this patch, you can return your site to its pre-patch state just by replacing your edited tagadelic.module and refine_by_taxo.module files with fresh versions.
#2
Sorry, I'm getting ahead of myself... In refined_by_taxo, the following code should be inserted where the tagadelic placeholder is:
if (module_exist('tagadelic')){
$tids = array();
$vids = array();
foreach($terms as $term){
$tids[] = $term->tid;
if (!in_array($term->vid)) $vids[] = $term->vid;
}
if (count($tids) != 0 && count($vids != 0)) return theme('tagadelic_weighted_refined', tagadelic_get_weighted_tags($vids,4,60,$tids));
}
And the following function should be added to the end of the refine_by_taxo file:
/*** theme function that renders the HTML for the tags
* @ingroup themable
*/
function theme_tagadelic_weighted_refined($terms) {
foreach ($terms as $term) {
$output .= '<a href="'. refine_by_taxo_build_url($term->tid, $op) .'" class="tagadelic level'.$term->weight.'">'. $term->name .'</a>';
}
return $output;
}
Sorry for the mistakes in the first one!
#3
Here's a patch, I've tried to make the code Drupal-compliant this time :)
#4
You'll also need the tagadelic patch here: http://drupal.org/node/81374
#5
I changed tagadelic a lot recently to allow external modules to use it for whatever clouds they want to print.
Here is a new start of a patch, containing comments, for tagadelic integration
#6
and now the patch.
#7
Is there any news on this? It's something I'd be very interested in getting my hands on. In fact if it only needs a wee bit of work I'd be willing to pay to get it done.
#8
Subscribing
#9
that would be so nice to have (subscribing)
#10
A review would be very usefull (hint ;) )
#11
Will the patch from September 26, 2006 - 21:06 work with todays code tagadelic+refine? 5.x
That would be awsome :)
Thank you!