CodeIgniter Forums
Create a tag cloud (kind of) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Create a tag cloud (kind of) (/showthread.php?tid=13184)

Pages: 1 2


Create a tag cloud (kind of) - El Forum - 11-14-2008

[eluser]iDenta[/eluser]
waldmeister: There we have it! Now it is working as i wanted it to, thanks!

All there is to do now is to make it look like a tag cloud, so that the font size changes according to have many times each word occurs.

I made a simple test with if blabla then font-size: 16px; like:

Code:
if ($row->total < '10')
{
  echo '<span style="font-size: 10px;">'.$row->word_list.'</span>&nbsp;&nbsp;';
}
elseif ($row->total > '20')
{
  echo '<span style="font-size: 16px;">'.$row->word_list.'</span>&nbsp;&nbsp;';
}

And, although it works, there must be some better way to do this... I had a look in the code for FreeTag, but couldn't figure out a better way to do it.

Did i say i'm a newbie at this? Smile


Create a tag cloud (kind of) - El Forum - 11-14-2008

[eluser]drewbee[/eluser]
Why not have the font size increase based on the views? Lets say for only 1 occurance of a word, you will display it at 10px up to a maximum of 30px

Code:
$base = 10; // 10 px
$max = 30; // 30 px
$size = $base * $row->total;

if ($size > $max)
{
    $size = $max;
}
echo '<span style="font-size: ' . $size . 'px;">' . $row->word_list . '</span>&nbsp;&nbsp;';

There you go. you have a dynamically changing font size based on word count just by using simple math with a minimum of 10 px and a maximum of 30px