Hi,
This is a feature request that came through Drigg - http://drupal.org/project/drigg . Tons of people are using Tagadelic since it come with the stock "Drigg distribution".
Somebody pointed out that it would be _great_ to only allow the tag cloud to consider promoted stories. This will be good because for example stories which are later reported as spam, and which would have added tags, won't be allowed to push tags into the cloud.
Please accept my apologies for not submitting this as a "proper" patch. I am already using a patched version of Tagadelic (my previous caching patch which never made it to 5.x) and am getting a little confused.
Basically, just add this to tagadelic_settings() :
$form['tagadelic_only_promoted'] = array(
'#type' => 'checkbox',
'#title' => t('Only consider tags of promoted stories'),
'#default_value' => variable_get('tagadelic_only_promoted', FALSE),
'#description' => t('It will only display tags for stories that were promoted.'),
);
And this to tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60):
if(variable_get('tagadelic_only_promoted', FALSE) == TRUE ){
$promote_filter_join =" LEFT JOIN {node} nn ON n.nid = nn.nid ";
$promote_filter_where =" nn.promote = 1 AND ";
}
$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 '.$promote_filter_join.' WHERE '.$promote_filter_where.' d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
Obviously, this is in place of the original $result = db_query_range(...)
This patch is functional right now in http://www.fsdaily.com
This really ought to be easy to commit to any version of Tagadelic.
Thank you for writing it!
Merc.
Comments
Comment #1
mercmobily commentedHi,
Short update:
http://www.drigg-code.org/node/111
This is the forum link in Drigg where the user requested it.
Merc.
Comment #2
Bèr Kessels commentedPlease refer to the inline doc at tagadelic_build_weighted_tags()
You can build a tiny module that queries the database (refer to tagadelic_get_weighted_tags()) and pass that along to _build_.
That way you can run ANY query and show the result in a cloud.
Also refer to the project I created to allow people such as you to build such a module simpler and easier: http://drupal.org/node/253514
Comment #3
mercmobily commentedHi,
Which version of tagadelic are you referring to?
Merc.
Comment #4
mercmobily commentedHi,
I am not sure I follow you. http://drupal.org/node/253514 seems to be an open issue. Has this been implemented already? If so, in which version of the module?
Merc.
Comment #5
Bèr Kessels commentedit is open. But so is this one... :)
Comment #6
mercmobily commentedHi,
Actually, this issue is "won't fix", which is different to "open" -- fact, it's pretty much "closed".
Also, you wrote:
"You can build a tiny module that queries the database (refer to tagadelic_get_weighted_tags()) and pass that along to _build_.
That way you can run ANY query and show the result in a cloud."
Is there a stable version that actually allows this?
Merc.
Comment #7
mercmobily commentedHi,
OK, I can see what you're saying.
I can see how writing a separate module would "fix" the issues. However, a separate module would also need to:
* Have configuration options etc.
* Have basically a lot of the stuff that is right now in tagadelic.module
I think a few *basic* things should be in the module. For example, only querying promoted articles is something that is quite basic and is likely to prevent several people from writing a whole new module.
I won't insist... but this is my last attempt to ask you to please consider the patch. If not, I will maintain a fork just for Drigg.
Bye,
Merc.
Comment #8
Bèr Kessels commentedAll issues you rase can (and should) be addressed in http://drupal.org/node/253514
* config options: No need for them, you could just "expand" on another tagadelic module (i.e. take their variable_gets). In any case: we should think of 253514 in a way to avoid what you foresee as problems.
* A lot of stuff that is.... This is plain wrong: You don't. As you say, all you want is an alternative cloud with an extra filter. Why do you then think you need all the other stuff. Besides: the basic modules in 253514 should contain "A lot of stuff that is right now in tagadelic.module"
It sounds to me that you are either not understanding what it is I want in 253514, or else that you don't want to understand it and try to push a patch that I (and IMO mayority of hte users) don't need, trough.
Maintaining a fork? I don't liek the sound of that, especially since it is propsed above as if to put more pressure on me "commit or else I will fork". Let me hope that was not the intention. And let's try to constructively make 253514 something you are happy to use too!
To get you excited, here are some brainwaves:
* hook_cloud_query() { call modules and see if they have a DBqeury for me so that I can make a cloud available at a certain page. (e.g. tagadelic/modulename/variation)
* theme_cloud_items($items, $title = ''); (very alike theme_list_items)
* tagadelic_weigted_tags($items) (eats any kind of $items, with a ->count var and returns an additional ->level)
I think /you/ are looking mostly at the first one. But I could see the others being really handy too (show node-titles in a cloud; weights based on amount of reads, to name a random example)
Comment #9
mercmobily commentedHi,
No need to nastiness or hard feelings.
I don't mean to push the patch down your throat. I thought it would be a rather common request, something that it's be worthwhile to put in the "core" tagadelics. If it isn't, that's fine.
Mine wasn't a threat to fork...! I am effectively _already_ maintaining a modified version of Tagadelic in drigg-distr.tgz. In it, I cache the query results (something that is now available in 1.x-rc1, I believe) and this patch I proposed here. This is because I need those two things for Drigg (which is very heavy in queries, and shouldn't count tags for unpromoted stories.
I already spend countless hours working on Drigg. I might be missing something in 253514: it looks to me like a proposal for further development of Tagadelic. I hav to be honest here: I already spend countless hours every week on Drigg (and yes, that's unpaid work) and really don't have the means to help with active development of other modules :-( This is not to be nasty: simply pragmatic. I am sitting *right now* on some important requests in Drigg that will take the best part of this week.
For what it's worth, I think you are definitely in the right direction with the new direction taken by Tagadelic. I will definitely use those hooks as soon as they are available, since the last thing I want to do is maintain a slightly modified version of Tagadelic (which is, no doubt, messy).
Bye.
Merc.
Comment #10
Bèr Kessels commentedhttp://drupal.org/node/141682