Hello all!
I have recently installed This (http://custom.simplemachines.org/mods/index.php?mod=579) mod from SMF and my members are really enjoying it :)
Is it possible to add the Tag Cloud in a block snippit?
My coding skills aren't that great ( none lol ) so i thought i'll ask it here with all the master coders ;D
After a few false starts, this is the code that works. Put the following in a php box:
global $db_prefix, $scripturl;
$query = "SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY l.ID DESC LIMIT 50";
$result = db_query($query, __FILE__, __LINE__);
$tags = array();
$tags2 = array();
while ($row = mysql_fetch_array($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['ID_TAG'];
}
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 100; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 5)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo $poptags;
global $scripturl, $smcFunc;
$result = $smcFunc['db_query']('', '
SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {db_prefix}tags as t, {db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY l.ID DESC LIMIT {int:limit}',
array('limit' = 50)
);
$tags = array();
$tags2 = array();
while ($row = $smcFunc['db_fetch_array']($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['ID_TAG'];
}
$smcFunc['db_free_results']($result);
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 100; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 5)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo $poptags;
Ahh thank you JPDeni, would be really great if you can do this ;D
I can't test it out, because I don't have the mod installed, but it looks like you should be able to use the code from the mod in a block.
[bad code removed to prevent confusion]
I'm sorry, i tried it in a scriptbox, phpbox and htmlbox and it's not working yet :(
With the phpbox i get a parse error:
Parse error: syntax error, unexpected $end in /home/..............public_html/forum/Sources/Load.php(1753) : eval()'d code(35) : eval()'d code on line 70
and with the scriptbox you see the whole code appearing..
It goes into a php box. (I always forget to mention that. Sorry. :) ) Just about everything that I write goes into a php box.
[bad code removed to prevent confusion]
If this doesn't work, I don't know what to say. I can't test it unless I install the mod, and I don't want to install the mod.
I'm sorry, it isn't working, now the block stays empty.. Is there anything i can do so it's easier for you to see what the problem can be? :)
I suppose you could give me full admin rights to your site. But not today. I'm going to be offline for the rest of the day.
Quote from: JPDeni on February 28, 2007, 07:30:52 PM
I suppose you could give me full admin rights to your site. But not today. I'm going to be offline for the rest of the day.
Ofcourse, no problem.. please let me know when you have some time to do this :) Thanks again JPDeni :)
My migraine lifted (thank goodness for drugs!), so if you want to set up an account for me where I can access the blocks and the error log on your site, I'll see if I can figure out what the problem is. Send me a private message with a link to your site and the account info.
Well, now don't I feel like a doofus? :uglystupid2:
After working on your site for a little bit, I found the problem. There was no command to actually print them out. :2funny:
I've added the right code to your site and edited it here for others to use.
Blame it on the migraine. Yeah, that's it!! ::)
YOUR AWESOME!!! ;D It looks really cool!! Me so happy now haha, don't know what to say.. my first request here, it's a special day today LOL
And to bad you have these migraines JPDeni, it's not nice.. but still, you're great! ;D
If others are to use this code, to reduce the number of populair tags change:
ORDER BY l.ID DESC LIMIT 25";
Can't thank you enough!! :laugh:
LOL! Well, I'm glad I figured it out and I'm glad you are happy with the results. It does look cool.
The migraines aren't fun, to be sure, but I'm used to them. They just sorta get in the way of thinking sometimes.
Yes i'm really happy with the results! :)
One question, when i reduce the number of tags in the snippit, this also affects the main page of Tag Modification, is there a way to only reduce them in the block? :)
I think it may be because of the variable used. See if this works:
[code moved to second post in topic]
That works great!! ;D Shall i update the first post with this new code JPDeni?
I'll update my posts with the correct code and clean things up a bit for future reference. I'm sure there will be others who will be interested in using this.
JPDeni:
The code generates a tag cloud just fine, thanks you 8)
A question, please - it is supposed to produce texts of varying size, because it does not do that for me?
Thanks
Yes, it is, if the members have different numbers of posts. If all of them listed have the same number of posts, then the text would all be the same size.
Then I have a problem, as the members listed have different numbers of posts, yet the font size remains the same.
I am using the code from the second post:
]global $db_prefix, $scripturl;
$query = "SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY l.ID DESC LIMIT 50";
$result = db_query($query, __FILE__, __LINE__);
$tags = array();
$tags2 = array();
while ($row = mysql_fetch_array($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['ID_TAG'];
}
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 100; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 5)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo $poptags;
I'm sorry. I was thinking of the Poster Cloud. Too many clouds! :)
Yes, the tags should be different sizes, depending on how many posts there are with each tag. I know that it worked for soMzE, because I saw it on his site. Can I get a link to your site?
thanks tiny portal i have been drinking coffee all day working trying to figure this out ..........
thanks alot you guys rock
cheers
10x for the code i'll use this for sure
Thanks for this! It works like a charm!
Congrats JPDeni !!
Just began to use your fantastic block code, I've have one question:
Is it posssible to show the tags in alphabetical order instead the actual one (new tags first)?
Thanks in advance for your time
You could try changing
ORDER BY l.ID DESC LIMIT 50
to
ORDER BY t.tag LIMIT 50
Thanks for your quick answer.
It's ok... But the order is reversed... I mean it's Z-A instead of A-Z
Thnak you again for your time
Try
ORDER BY t.tag ASC LIMIT 50
Simply perfect! :D Thank you very much!
Excuse me for annoying you with my requestings. I'm not an SQL expert and I'd like to make you another question... ::)
So, I want to show "N" tags in my block, and I want to show most popular ones and alphabetically...
I was trying this:
ORDER BY l.ID, t.tag ASC LIMIT 50";
and this:
ORDER BY t.tag, l.ID ASC LIMIT 50";
but none of these works like I want...
Sorry for disturbing you with my askings. Take your time for this. I'm not in a hurry.
Thanks in advance for your time JPDeni.
I don't think you can do it with the ORDER BY command. You would need to get the information for all the tags, loop through them, putting the most frequent N tags into an array and then loop through again, putting them in alpabetical order. I can try to write the code later, but it's very early in the morning where I am and I've only just woke up.
Ok. Please, take your time and thank you again :)
Hello there... Any idea about this?
Please take your time. I'm not in a hurry, just I want you to remember it.
Thanks in advance for your time :up:
I can't work it out. Sorry. Maybe someone else has a clue.
Ok, don't worry. Maybe anybody else would be interested in trying to make it.
In addition, I will look for a code that do it and maybe could be adapted to work.
Thanks again for trying :up:
Well, I think this sentence can work...
To remember it, what I want is show the most popular N tags:
SELECT * FROM
(
SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY t.tag DESC
)
WHERE ROWNUM <= N
But this causes a 'hacking attemp' error...
I think I'm in the way to make it, but I need a little help...
Can anybody figure it out?
This block snippet gives me an internal server error.
Does this mean I need to change something in the code to get it to retrieve from MySQL or is this a copy paster snippet? OR do I install the SMF mod then use this block?
You first have to install Tagging system for topics mod: http://custom.simplemachines.org/mods/index.php?mod=579
And then you can use this snippet.
Quote from: 3nd3r on October 10, 2007, 08:41:33 AM
You first have to install Tagging system for topics mod: http://custom.simplemachines.org/mods/index.php?mod=579
And then you can use this snippet.
Thanks I'll try it out when I get a chance. I already have the "googletagged" mod and thought that would be a nice front page center block. I'll have to read up if these 2 mods will conflict each other since they are quite similar
Works perfect. With this snippet I didn't have to manually install any part of the mod with my custom theme. Thanks.
OK spoke too soon, Please help -
Does anyone know how to implement a better word wrap on this? I have this on a narrow side panel and it doesn't obey the panel px settings in the TP admin page. The big font (which I did decrease max size to ~200) rolls off the side of the page or older versions of IE it increases the panel size for it to fit.
Thanks ahead,
C.P.
I want to show tags from a single board like tag cloud from single board.
Quote from: catchpen on October 26, 2007, 03:25:24 PM
Does anyone know how to implement a better word wrap on this? I have this on a narrow side panel and it doesn't obey the panel px settings in the TP admin page. The big font (which I did decrease max size to ~200) rolls off the side of the page or older versions of IE it increases the panel size for it to fit.
I'd also like to implement this. Is there a way of echoing the output so it is centered and justified?
Many thanks
Quote from: falguni1 on January 09, 2008, 12:34:31 PM
I want to show tags from a single board like tag cloud from single board.
any help.
QuoteI want to show tags from a single board like tag cloud from single board.
I don't know what that means. Could you reword your request? Possibly an example of what you want would help.
means
it shows tags from all boards
I want is there are two boards
both boards have tags.
show tags from only board 1.
like this
http://www.tinyportal.net/index.php?topic=1234.0
where you get topics from certain boards.
It depends on how the mod sets up the tables. I don't remember how things are set up. Does it include which board the tag is from in the database?
will it help if I post the code from the file if you tell me which file you want to see.
I dont understand php much.
tagsql.php
<?php
//SMFHacks.com
//Table SQL
//Create Tags Table
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}tags`
(`ID_TAG` mediumint(8) NOT NULL auto_increment,
`tag` tinytext NOT NULL,
approved tinyint(4) NOT NULL default '0',
PRIMARY KEY (`ID_TAG`))", __FILE__, __LINE__);
//Create Tags Log
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}tags_log`
(`ID` int(11) NOT NULL auto_increment,
`ID_TAG` mediumint(8) unsigned NOT NULL default '0',
ID_TOPIC mediumint(8) unsigned NOT NULL,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`ID`))", __FILE__, __LINE__);
//Insert the settings
db_query("REPLACE INTO {$db_prefix}settings VALUES ('smftags_set_mintaglength', '3')", __FILE__, __LINE__);
db_query("REPLACE INTO {$db_prefix}settings VALUES ('smftags_set_maxtaglength', '30')", __FILE__, __LINE__);
db_query("REPLACE INTO {$db_prefix}settings VALUES ('smftags_set_maxtags', '10')", __FILE__, __LINE__);
?>
It looks as though the board number is not saved with the tag. Therefore, it would be impossible to list the tags by board.
how to make the board number to save with the tag please help.
I would contact the author of the mod and ask him or her how to alter the code.
I am very glad.
it will be very useful if we have a prgramming community with boards c programming and html.
c programming will have tags like loop, variables
and html will have tags like tables, borders
so it willl be nice to see tags from c programming only in the c programming board only.
How is C related to TP community?
And almost every language got loops and variables...
Quote from: Dragooon on January 26, 2008, 04:38:06 AM
How is C related to TP community?
And almost every language got loops and variables...
it is an example.
Quote from: SteveW on January 14, 2008, 10:00:45 PM
Quote from: catchpen on October 26, 2007, 03:25:24 PM
Does anyone know how to implement a better word wrap on this? I have this on a narrow side panel and it doesn't obey the panel px settings in the TP admin page. The big font (which I did decrease max size to ~200) rolls off the side of the page or older versions of IE it increases the panel size for it to fit.
I'd also like to implement this. Is there a way of echoing the output so it is centered and justified?
Many thanks
Hi guys - I was wondering if anyone has a method of doing this? If you look at my main page (no need to register) under the centre gallery block, the tags are all aligning to the left. Is there a way of making them centred?
My site is http://www.alienexistence.com
much appreciated
I would think that the way to make them centered would be to add centering tags.
Assuming that you're using the code in the second post of this topic (I haven't looked through to see what else might be there), instead of
echo $poptags;
you would use
echo "<center>" . $poptags . "</center>";
Also, to faguli, you may have misunderstood me. I'm not going to contact the writer of the mod. You will need to do that.
I will contact him at the earliest. :D.
please tell me wot should I write to him and wot all should I ask him. :-\.
Tell him you would like to be able to list the tags by board and you need to be able to save the board ID along with the tag. This will require a change in the database table as well as a change in the way data are written to the table.
ok.
Thankyou JPDeni, that centre code worked a treat :)
Quote from: SteveW on January 27, 2008, 06:15:26 PM
Thankyou JPDeni, that centre code worked a treat :)
after doing that you can also change " if ($row_count > 5)" to " if ($row_count > 10)" or more or less to fill in the sides of the center block.
I have read through this topic so if this has already been answered, forgive me if I missed where this was posted.
How can I get the tags to appear like they do in the Poster Cloud? (different sizes depending on how often a tag is used)?
Thanks
http://www.tinyportal.net/index.php?topic=13744.msg115684#msg115684
I already found it in the code and adjusted it. .Thanks
Found a glitch and I am not sure if it involves the code for the tag cloud or for the tag mod so I have posted it on the smf site for the mod creator to see, as well has here :)
its not linking the same tag words correctly in the cloud. If the same exact tag word is put on multiple topics, but not in the same order, it creates duplicate tags in the cloud - and also will not pull correctly when the tag is clicked on.
Example: (3 topics)
1st topics tags: Jokes
2nd topics tags: Comedy, Jokes
3rd Topics tags: Comedy, Jokes
(the "jokes" tag is in the 1st spot on topic 1 and in the 2nd spot on topics 2,3)
There will be 2 seperate tags in the cloud for "jokes". When each tag is clicked on, 1 brings up only 1 topic, the other brings up the other 2 topics. When I changed the order of the tags so that the tag "jokes" was in the 1st spot on all of them, it removed the 2nd tag in the cloud and then when the tag "jokes" was clicked on, all 3 topics then appeared on the list like they are supposed to.
Any ideas as to how this can be fixed? Thanks :)
I don't know if I would help you, but are you writing the tags separate with commas and no spaces?
I mean,
You wrote:
1st topics tags: Jokes
2nd topics tags: Comedy, Jokes
3rd Topics tags: Comedy, Jokes
And the right way, as far as I know, must be:
1st topics tags: Jokes
2nd topics tags: Comedy,Jokes <-- no spaces between, only commas
3rd Topics tags: Comedy,Jokes <-- no spaces between, only commas
Could be these spaces your problem?
You know, I actually wondered about the whole space thing when I first installed the mod (having not using the cloud yet), and since it doesnt specify "no spaces", I assumed that it was set up just like the box you have when entering multiple names when sending pm's (it doesnt specify either however, spaces are used inbetween those).
I will test your theory and let you know. Thanks for the response :)
Great Block bro...Works perfectly...Good for SEO of site as well....Thank you very much...
I love this mod, and by adding the block it could really be a big thing for my site. I do have 1 question though.
Is there a way to make the font sizes of the tags inside the block random, after all that is the purpose of the "cloud".
I read through the entire thread here, and if I missed it I apologize, but I don't believe I did.
Thanks, great work JPDeni
I apologize, I just realized that when a tag is used twice, the size changes. This block is complete O0
Hi JPDeni sorry to revive this old post but I wonder if you can do the same with the GoogleTagged (http://custom.simplemachines.org/mods/index.php?mod=1245) Mod... :-\
I don't know. There would be no way for me to test any code that I write even if I installed the mod. People don't use Google to access my test site and I'm not going to install it into my live site.
I don't have a clue about the code that's in this topic, since I haven't looked at it in months. I'll take a look at the code and the mod and see if there's anything the two have in common.
But I wouldn't hold out a lot of hope if I were you.
Hi - I have this tag cloud on my website but I cannot get the fonts to change size, they all appear normal size:
my site is http://www.alienexistence.com
For some reason, your font sizes are all the same -- 95%. It could be that all of your tags appear equally on your site. If you want me to debug the code, you'll need to post the code for me to debug.
This is the code:
global $db_prefix, $scripturl;
$query = "SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY l.ID DESC LIMIT 50";
$result = db_query($query, __FILE__, __LINE__);
$tags = array();
$tags2 = array();
while ($row = mysql_fetch_array($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['ID_TAG'];
}
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 95; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 6)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo "<center>" . $poptags . "</center>";
thankyou
Possibly the person who wrote the code will come by (or you could send him/her a PM). I don't have the mod installed, nor a site where I would be able to test various things to debug. It looks like it should work.
Hi JPDeni, I have messed about and your right it does work, when I add a similar tag the font increases. The tags obviously haven't got enough tags to increase the font.
Would it be easy enough to pull random tags rather than the latest tags?
It should work if you change
ORDER BY l.ID DESC LIMIT 50";
to
ORDER BY RAND() LIMIT 50";
Thankyou works lovely
Cool! 8)
I love the random stuff.
Hi JPDeni.. thanks for the great code..
it work fine for me.. :)
A Question, How to make the tag list show with different color? and is there anyway to set the height size for this block?
Best Regards
Make sure you log out and view your forum-posts after installing the SMF tag mod. I did and the layout when I was logged in as administrator looked fine, as any lesser member or guest it was broken. Functionally fine, but didn't play nice with the TP blocks.
This was just with the SMF tag mod, I wasn't feeling it so I just uninstalled it and everything went back to normal.
Maybe if you're going to use this, you need to install the tag mod first, then reinstall TP?
QuoteHow to make the tag list show with different color?
You can add inline css code via div tags. Take a look at the code. I'm sure you'll be able to figure out where it would go.
Quoteis there anyway to set the height size for this block?
Not that I know of.
This is a great snippet, thanks a lot JPDeni!
Just one question:
How can i make the string "thiungs tagged with" in $poptags .= ' title="'.$value.' things tagged with '.$key.'"'; language selectable?
Thanks in advance.
QuoteHow can i make the string "thiungs tagged with" in $poptags .= ' title="'.$value.' things tagged with '.$key.'"'; language selectable?
Not a clue. What would a link look like? What would it link to? (I'm assuming that by "selectable" you mean a link.)
When you hover over a tag, it shows the string "X things tagged with <tag>". I would like to change that string with the forum's language. I have three languages in my forum and would like to show that string on each of them.
I know which string to change, but i don't know how :'(
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg14.imageshack.us%2Fimg14%2F7691%2Fsemttuloioa.jpg&hash=a2906677b7677a45f1044ace18dd7dc4e4c96740)
I'm sorry. I didn't see the word "language" in your previous post.
You need to translate "things tagged with" in those languages, yes? The thing to do would be to open up the Themes/default/languages/index.language.php file. (Substitute language for the languages that you want to define.)
Add a line to each file with the text
$txt['tagcloud'] = 'things tagged with';
In each one, use the same code, but translate the things tagged with part.
In the block code, change
global $db_prefix, $scripturl;
to
global $db_prefix, $scripturl, $txt;
Where it prints out the text use
$poptags .= ' title="'.$value.' ' . $txt['tagcloud'] . ' '. $key . '"';
Thank you so very much for your help, JPDeny. It worked beautifully.
Even with the tagcloud from the mod itself.
Cheers ;)
Here i am once more :)
I noticed that when we click on a tag it doesn't redirect us to the correspondent tagged topics, as it happens with the tagcloud of the original mod.
I noticed that the link for the topics tagged with a certain word is as follows:
http:/mysite/index.php/action,tags/tagid,132.html
And the links from the tagcloud block is:
http:/mysite/index.php/action,tags/id,132.html
I believe this is the problem, any ideas on how to fix this?
Thanks.
Edit: I found the solution. I changed
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
to
$poptags .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
It worked :)
:up: Good for you for working it out.
Sorry to dig this up, but i saw something in another blog that i would like to see with this snippet.
Is there any chance to attribute different colours to the tags like in here (http://juramentosembandeira.blogspot.com/)?
Thanks in advance.
someone have code for Tag Cloud (from Tagging System http://custom.simplemachines.org/mods/index.php?mod=579 ) to display it in block ?
sorry for my english..
Have you tried the code from earlier in this post?
yes, i tried this code:
global $db_prefix, $scripturl, $txt;
$query = "SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l WHERE t.ID_TAG = l.ID_TAG
GROUP BY l.ID_TAG
ORDER BY RAND() LIMIT 50";
$result = db_query($query, __FILE__, __LINE__);
$tags = array();
$tags2 = array();
while ($row = mysql_fetch_array($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['ID_TAG'];
}
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 95; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 6)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo "<center>" . $poptags . "</center>";
and it does not work (i use SMF 2.0RC3 and TP 1.0RC1) :/
Replace all instances of db_query with tpdb_query
Thanks, now it works perfectly ;)
Cool, I'll probably add this to my own site! Should we add this to the snippet index?
Feel free to add anything to the snippets index.
This snippet is not work on SMF2 and last TP . How fix it ?
Updated the code in the origin post on page to with code for SMF2. Let me know if it doesn't work.
it doesn't work :( Can be because i use Pretty URLs mod? But earlier all was good with Pretty too
I am use this code:
global $scripturl, $smcFunc;
$result = $smcFunc['db_query']('', '
SELECT t.tag AS tag, l.id_tag, COUNT(l.id_tag) AS quantity
FROM {db_prefix}tags as t, {db_prefix}tags_log as l WHERE t.id_tag= l.id_tag
GROUP BY l.id_tag
ORDER BY l.id DESC LIMIT {int:limit}',
array('limit' => 50)
);
$tags = array();
$tags2 = array();
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['id_tag'];
}
$smcFunc['db_free_result']($result);
if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 100; // min font size in %
// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);
// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 5)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo $poptags;
I do not have the mod installed so I cannot test it. You saying "it doesn't work" does not give me anything to help you with. You need to give me any errors you may have in your SMF or server log. It would also help if you describe what doesn't work. Does it show a blank page? Does it not show anything? I need info if you want help.
Quote from: IchBinâ,,¢ on September 17, 2011, 10:44:27 PM
I do not have the mod installed so I cannot test it. You saying "it doesn't work" does not give me anything to help you with. You need to give me any errors you may have in your SMF or server log. It would also help if you describe what doesn't work. Does it show a blank page? Does it not show anything? I need info if you want help.
Sorry !
In error log i do not have any errors for tags cloud. In main page block shows, but empty:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.paraplanoff.net%2FMGalleryItem.php%3Fid%3D15059&hash=65135026f22090cbe4a45c3529f4efc919332661)
I am add in end of block code string
echo 'test string'; , but it not shows
Now I am test this block in clean install SMF+TP , and have this error:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.paraplanoff.net%2FMGalleryItem.php%3Fid%3D15060&hash=b1f6140c72f7970763bf742a406111f356097bde)
In your database, are the tag table rows named the same as in the query?
Is it still "ID_TAG"? Or is it now "id_tag"?
in database on fresh install and in my working database - "id_tag" (small text)
i am rename it in query but it not work ^(
You must update all the columns that changed. l.ID is probably l.id now too. And don't forget in the php code there are references to ID_TAG as well. I've changed them all in the code above, see if it works.
Don't respond with "it don't work"... If it's not working you need to post errors from the SMF log or server error_log.
ok, thenk you for help!
i install this code but have a error in block:
Parse error: syntax error, unexpected '=', expecting ')' in /usr/local/www/data-dist/saks/Themes/default/TPsubs.template.php(114) : eval()'d code on line 8
I am tested it on test forum with TP (http://koritssa.ru) , and have error:
Parse error: syntax error, unexpected '=', expecting ')' in /home/saks1/koritssa.ru/docs/Sources/Load.php(2173) : eval()'d code(114) : eval()'d code on line 8
it.s forum with only TP , Tags mode and Aeva...
Grant you the rights of the administrator to this site for test this block?
Edited code in this post, try it again.
http://www.tinyportal.net/index.php?topic=13744.msg275015#msg275015
Quote from: IchBinâ,,¢ on September 23, 2011, 05:26:53 AM
Edited code in this post, try it again.
http://www.tinyportal.net/index.php?topic=13744.msg275015#msg275015
I am try it again but have error :
Fatal error: Function name must be a string in /home/saks1/koritssa.ru/docs/Sources/Load.php(2173) : eval()'d code(114) : eval()'d code on line 14in smf log :
http://koritssa.ru/index.php?
8: Undefined index: db_fetch_array
File: /home/saks1/koritssa.ru/docs/Themes/default/languages/TPShout.english.php (tp_above sub template - eval?)
Line: 14
Updated code again.
Quote from: IchBinâ,,¢ on September 23, 2011, 03:19:25 PM
Updated code again.
Now it show error:
Fatal error: Function name must be a string in /home/saks1/koritssa.ru/docs/Sources/Load.php(2173) : eval()'d code(114) : eval()'d code on line 20
Grrr.... Should be the last edit. Try again.
Wow! IchBin, you is guru! Now it work perfect, thank you very match! :)
Quote from: saks on September 26, 2011, 02:31:42 AM
Wow! IchBin, you is guru! Now it work perfect, thank you very match! :)
No problem! Sorry it took so long! lol
Hi.
I have the code you posted in a block and it works BUT is there a way to have one tag per line ?
(narrow right hand block)
Thanks
That should be doable with some CSS. If you need help with that post a link where I can see your block.
Thanks Willy :)
I noticed some code that allowed me to get one per line (apart from the first line for some reason) with some trial and error.
One other thing is that if I click on any tag in the box it just takes me to the tags page rather than the specific tag. Is there a wat to change that do you know ?
I'm not a php coder, I haven't a clue. But it sounds like a good idea, that's how I would expect a tag cloud to work.