0
Recommendations
Summary:
Tagcloud Widget
Full description:
This is an update of the randomized Tagcloud widget for Elgg 1.5. I've also included a function for including a tag cloud on a front page or similar page.
The function returns a string with the formatted tags. You just need to wrap it with a div or something similar for formatting. It is called like this:
$tagcloud = frontpage_tagcloud(25);
The only parameter is the maximum number of tags. It only displays tags that are associated with public content. Note: if you call display_tagcloud() it will not return a randomized array. You need to call frontpage_tagcloud() or set the context to random (see the view code of the widget for an example).
As with previous versions, two or more objects must be tagged with a tag for the tag to show up.
Previous Versions by Karsten Schulze and Sammy Kanan.
2elggboy:
1. Open tagcloud/views/default/output/tagcloud.php
2. Find this line:
if ($size < 60) $size = 60;
3. Place next code below:
if ($tag->total < 3) {
$color = "#1560BD";
}
if ($tag->total == 3) {
$color = "#aa0685";
}
if ($tag->total == 4) {
$color = "#00A86B";
}
if ($tag->total == 5) {
$color = "#00FF00";
}
if ($tag->total == 6) {
$color = "#FFCC00";
}
if ($tag->total == 7) {
$color = "#CC5500";
}
if ($tag->total == 8) {
$color = "#FF4500";
}
if ($tag->total == 9) {
$color = "#964B00";
}
if ($tag->total == 10) {
$color = "#FF4500";
}
if ($tag->total == 11) {
$color = "#960018";
}
if ($tag->total > 11) {
$color = "red";
}
4. Change this line:
$cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
$cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%; color: {$color}\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
Pavel M 360 days ago
Is there a way to exclude wire posts from the cloud?
I do not know if it is still like this but thewire was saving every word as a tag which results in "big" tags for words like "and" and so on.
Dahaniel 360 days ago
@Dahaniel - The wire stores the text in the description field on an ElggObject. The words will not show up as tags.
Cash 360 days ago
@Cash - Yes, I just saw that, but a older version of thewire, every single word was saved as a tag. So no I have to find a way to delete all the old "bad" tags....
How can I find a tag in the database? Is it in the metasrtings table? And could I simply delete it from there?
Dahaniel 360 days ago
@Dahaniel - I don't know the structure of the old wire so I can't tell you exactly how to remove old wire posts. If it was an object with each word as a piece of metadata, you'll have to work with the entities table, object table, metadata, and possibly the metastring table. It might be possible to write a script that calls core Elgg functions that deletes the entity and all associated data.
Tags are metadata. First find the string "tags" in the metastrings table and note its id. Then search the metadata table for name_id = that id. This will be all the tags. To find the value of the tag, note its value_id and look in the metastring table for it.
Cash 360 days ago
What front page do you mean? (You could mean the front if you're not logged in, the front if you are, a side panel if you use the river alternative dashboard...)
As specified above, you get the array of the tags with the statement:
$tagcloud = frontpage_tagcloud(25);
Then you have to create the HTML around it. One way to see what that looks like is to look at the widget rendering code looks like and copy that.
Ed Lyons 359 days ago
@Cash: Thank you for the hint, I think I do understand now how I would have to delete them. They are all tags. I think I will have to learn some mysql and write a tag management plugin, or I export everything and try to work with excel/openoffice ;)
Dahaniel 359 days ago
I did and it everything turns red. :-)
elggboy 359 days ago
If you want to add this to the custom_index you can use the following:
<?php
if(is_plugin_enabled('tagcloud')){
?>
<!-- display latest tags -->
<div class="index_box">
<h2>Tag cloud</h2>
<div class="contentWrapper")
<?php
echo display_tagcloud( 1, 25, "tags");//this will display tags
?>
</div>
</div>
Just add it to:
mod/custom_index/viewsdefault/canvas/layouts/new_index.php
Inde Uppal 358 days ago
@Inde
That won't have random tag sorting. To do that replace
echo display_tagcloud( 1, 25, "tags");
with
echo frontpage_tagcloud(25);
Cash 358 days ago
Ok thanks!
Inde Uppal 358 days ago
Correction from Cash!
<?php
if(is_plugin_enabled('tagcloud')){
?>
<!-- display latest tags -->
<div class="index_box">
<h2>Tag cloud</h2>
<div class="contentWrapper")
<?php
echo frontpage_tagcloud(25);//this will display tags
?>
</div>
</div>
Just add it to:
mod/custom_index/viewsdefault/canvas/layouts/new_index.php
Inde Uppal 358 days ago
Oh, and make sure you include the closing bracket if you're doing what Inde Uppal suggests:
<?php } ?>
Add it after the final </div>
Cash 358 days ago
@cash
Have you found any issues in getting to work with internet explorer and opera?
Inde Uppal 358 days ago
@Inde - The markup is very simple and should work in any browser. I tested with FF, IE, and Opera. The tag cloud respects the permissions on content so if you hit a page and are not logged in and all your content has the access level of "logged in", no tags will show up. Hope that makes sense.
Cash 358 days ago
@Cash
Cheers for the plugin, although I dont understand why it only show your tags in it and not the tags of all the files/blog/etc from across the site, like the 1.2 one did.
Am I missing something?
Regards.
munkee 355 days ago
@munkee - do you want that? I thought if the cloud widget was used on a profile, someone wanted to show their tags rather than everyone's tags. If you put it on the frontpage with the frontpage_tagcloud(); function, it does show all site tags (depending on permissions).
Cash 355 days ago
@Cash - We've got users that liked that feature of the old tagcloud, is it possible to add to the code ?
I suppose once they are logged in they just like being nosey, and like to have them to click, to see what content it takes them to :)
munkee 355 days ago
@munkee - find this line in the widget view.php:
echo display_tagcloud(1, $num_items, 'tags', 'object', '', page_owner());
and change to
echo display_tagcloud(1, $num_items, 'tags');
Cash 355 days ago
this is just what I want for my site, GREAT!
but i want a little modification please, what if I want to pull the tags which are only under a certain field in the profiles, let's say the interest field or some specific field that I've added.
thanks
zanzoon 351 days ago

elggboy
Profile
Edit profile icon
Friends
Friends of
Pages
Plugins
Hi and thanks for the updated plugin. Do you know how to make it display the tags in different colors?
elggboy 360 days ago