Tag Cloud

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 28, 2011   (RSS)

By ryanGT - October 27, 2011

Hi all,

i was just wondering how i would go about creating a tag cloud from one field across multiple tables?

I have two tables called Reviews and Features, both of which have a text field called page_keywords. I would really like to use the information in these fields to create a tag cloud.

I have tried a few things but to no avail, (including left join, and array merge) im sure that the php explode function will have to be involved somewhere, but everything i try doenst seem to work.

I think that array merge is the correct way to go, and would really appreciate some help.

Many thanks

Re: [Jason] Tag Cloud

By ryanGT - October 28, 2011

Hi Jason,

Thats exactly what i need, but instead of counting duplicates could the function remove duplicate values?

Also i am struggling with extracting the tags from the array, no matter what i do i seem to always just get the numerical values out of the array, needless to say php coding is not my strongest area.

Also when returning the results it would be really good to have the functionality to limit the number of results and display them in a random order.

Again your help would be greatly appreciated.

Many thanks

Ryan

Re: [ryanGT] Tag Cloud

By Jason - October 28, 2011

Hi Ryan,

When going through this array, each tag will only appear once, even if it's counted multiple times.

The problem you were probably encountering with getting the tags out of the array, is that the tags are actually the array indexes, not the values. You can try this after the previous code executes.

This example extracts all the tags into an array, randomizes the array, and then outputs the first 5 tags:

//extract tags from the array
$tags = array_keys($tagsToCount);

//randomize tags
shuffle($tags);


$maximumResults = 5;
$resultCount = 0;

foreach($tags as $tag) {

echo $tag;

if (++$resultCount == $maximumResults) {
break;
}

}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/