• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taggly, a tag-cloud library

Thanks again...!

[eluser]Gavin Vickery[/eluser]
Welcome Big Grin

[eluser]CI Lee[/eluser]
I will send you the link once I have it implemented...

Looks good!


[eluser]Majd Taby[/eluser]
Nice Gavin, this looks like something I could implement with JTaby for tags, thanks

p.s. nice blog Smile

[eluser]CI Lee[/eluser]
JTaby? Whats that?



[eluser]Gavin Vickery[/eluser]
Thanks Zaatar Smile If you do implement with JTaby, I'd be curious to see it.

Also, I thought of a possible 'upgrade' to Taggly last night. After looking through other sites using the tag-cloud concept, I noticed several use CSS styles to define the size and color instead of embedding it right in the tag.

<a href="http://..." style="font-size: 12px">Example</a>
<a href="http://..." class="small_font">Example</a>

This way you can define an array of styles to be used instead of font-sizes allowing you to not only apply font sizes, but other CSS styles too (color, text-decoration, background etc.).

.small_font {font-size: 12px; color: red;}
.medium_font {font-size: 20px; color: blue;}
.large_font {font-size: 30px; color: green; font-weight: bold;}

The logic would be a bit tricky, because you should be able to define any amount of styles to be used and still just pass an array of tags (I love expandability).

Does that make sense? What do you guys/gals think? Is this something wroth implementing?

[eluser]Majd Taby[/eluser]
It's a neat concept, but it would mean that a person who wants to use taggly would need to implement/maintain two files instead of one. just my 2cents

[eluser]Gavin Vickery[/eluser]
Well yes and no. They would only need to maintain two files if they wanted to use that functionality. Taggly's original core would still be there. You could just call a different function to use the CSS styles.

$this->taggly->styled_cloud($dataArray, $stylesArray);

Or better yet, just except a 3rd parameter in the Orignal funcion
$this->taggly->cloud($dataArray, $configArray, $stylesArray);

Besides, most websites have styles sheets now and days, so they are already maintaining a stylesheet as is.


I am having a bit of a problem with Taggly.
If I use a static array like below it works perfectly fine.

$tagsArray = array (
    array(10, 'Dog', 'http://dogs.com'),
    array(53, 'Cat', 'http://cats.com')

echo $this->taggly->cloud($tagsArray);

If I use the below code instead all tags are printed, BUT they
are all in the same size (11px) even though that the count is different.
I am not sure how to "fill" an array from the data base but this is what I have tried.

In the controller:

$data['tags'] = $this->db->get();

In the view file:

&lt;?php foreach($tags->result() as $tags): ?&gt;
&lt;?php $tagsArray = array (array($tags->count, $tags->name, 'http://dogs.com')); ?&gt;
&lt;?php echo $this->taggly->cloud($tagsArray); ?&gt;
&lt;?php endforeach; ?&gt;

Please help

Kind Regards,

[eluser]Gavin Vickery[/eluser]
Hey Daniel,

The problem is within your foreach statement. You are looping through each tag individually, and outputting the tag cloud each time. Because you are only ever passing one value, the size is always the lowest setting (11px).

What you need to be doing is creating the array before you call the Taggly cloud method.

Here is an example
// First build the 2D array
foreach($tags->result() as $tags):
    $tagsArray[] = array($tags->count, $tags->name, 'http://dogs.com')); ?&gt;

// Output Taggly Cloud
echo $this->taggly->cloud($tagsArray);

Also, depending on the structure of your query array, you could just do this:


Keeping in mind that the array returned from your SQL statement would have to be COUNT - NAME - URL for the above shortcut to work.

Hope that helps. Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.