I am having trouble getting a function to execute.
Here is the function as it is written.
function get_tag_cloud_html($freetag, $num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = 'cloud_tag', $tag_page_url = '/tag/')
{
$tag_list = $freetag->silly_list();
// Get the maximum qty of tagged objects in the set
$max_qty = max(array_values($tag_list));
// Get the min qty of tagged objects in the set
$min_qty = min(array_values($tag_list));
// For every additional tagged object from min to max, we add
// $step to the font size.
$step = ($max_font_size - $min_font_size)/($max_qty - $min_qty);
// Since the original tag_list is alphabetically ordered,
// we can now create the tag cloud by just putting a span
// on each element, multiplying the diff between min and qty
// by $step.
$cloud_html = '';
$cloud_spans = array();
foreach ($tag_list as $tag => $qty) {
$size = $min_font_size + ($qty - $min_qty) * $step;
$cloud_span[] = '<span class="' . $span_class . '" style="font-size: '. $size . $font_units . '"><a href="'.$tag_page_url . $tag . '">' . htmlspecialchars(stripslashes($tag)) . '</a></span>';
}
$cloud_html = join("\n ", $cloud_span);
return $cloud_html;
}
I am having trouble initializing or calling the function so it runs. Here is how I'm currently trying to invoke it in the same file:
get_tag_cloud_html($freetag);
I've tried leaving the (); and removing $freetag, but I get an error message saying there is a missing argument. When I leave ($freetag);, I don't get an error, but it doesn't return anything.
The $freetag variable is supposed to hold an initiated object called earlier in the file:
$freetag = new freetag($freetag_options);
I believe the freetag object is successfully being initiated because when I echo it it says Object ID #1.
I can't pinpoint where I'm going wrong, if it's in passing the object to the function or in initiating the function or both.
Thanks in advance.