22, November 2008

trouble with diff. sizes in tag cloud - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: trouble with diff. sizes in tag cloud
« previous next »
Pages: [1] Print

Author Topic: trouble with diff. sizes in tag cloud  (Read 996 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« on: May 11, 2007, 02:50:22 PM »

Hi I have a bit of problems with the calculation of the diff. font-size in my tagcloud:

in this metod I create the array and also the average from all value:
Code:
<?php
function 
build_tag_array() {
$result $this->get_records();
$i 0;
$counting 0;
while ($obj mysql_fetch_object($result)) {
$tags[$i]['name'] = $obj->tag_name;
$tags[$i]['clicks'] = $obj->tag_clicks;
$counting $counting $tags[$i]['clicks'];
$i++;
}
$this->avg_val $counting/$i;
mysql_free_result($result);
shuffle($tags);
return $tags;
}


and I create the tags with this code: (using a loop)

Code:
<?php
function 
create_element($tag_array) {
$diff_size $this->max_size $this->min_size;
$size $tag_array['clicks']/$this->avg_val*$diff_size;
$size round($size1);
$tag stripslashes($tag_array['name']);
if ($tag_array['name'] != $this->current_tag) {
return "<span style=\"font-size:".$size."em;\"><a href=\"".$this->page."?".$this->qs_var."=".rawurlencode($tag)."\">".$tag."</a></span>\n";
} else {
return "<span style=\"font-size:".$size."em;\">".$tag."</span>\n";
}
}

is this the right way to calculate the size values?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #1 on: May 11, 2007, 03:16:25 PM »

the max_size and min_size are the minimum and maximum clicks value?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: May 11, 2007, 03:47:00 PM »

the max_size and min_size are the minimum and maximum clicks value?
no the max and min font size


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #3 on: May 11, 2007, 05:39:58 PM »

I would use another way to do this. First you need three variables :

$maxFontSize
$clicks -> Clicks from the active tag
$maxClicks -> The higher clicks value from all tags

In that case the size of a tag would be :

ceil(($clicks $maxFontSize) / $maxClicks);


Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: May 11, 2007, 11:31:52 PM »

I would use another way to do this. First you need three variables :

$maxFontSize
$clicks -> Clicks from the active tag
$maxClicks -> The higher clicks value from all tags

In that case the size of a tag would be :

ceil(($clicks $maxFontSize) / $maxClicks);



thanks I will try that, but I want also a minimum size, maybe I should do that afterwards:

if size < 0.8 size = 0.8...


Last blog : Just a better Internet portal provided by Google
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: May 12, 2007, 05:02:25 PM »

I would use another way to do this. First you need three variables :

$maxFontSize
$clicks -> Clicks from the active tag
$maxClicks -> The higher clicks value from all tags

In that case the size of a tag would be :

ceil(($clicks $maxFontSize) / $maxClicks);



thanks I will try that, but I want also a minimum size, maybe I should do that afterwards:

if size < 0.8 size = 0.8...

I think I got it working thanks!


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6557
Tags : php array tag cloud Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: trouble with diff. sizes in tag cloud
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 04:30:00 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.397
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Janai

42 Guests, 8 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.