Hi,
There are a number of different method for creating tag clouds. However, you first need to get an array of all of your "tags" along with a count of how frequently they occur.
In this example, you first create an array of all the sections you want to use and which field in each you tags are stored in. This script assumes that the tags in each field are separated by commas. It is also assumed that you are using CMSB version 2.08 or greater:
$tagsToCount = array();
$sectionsToField = array('reviews' => 'page_keywords', 'features' => 'page_keywords');
foreach($sectionsToField as $sectionName => $fieldName) {
//get section records
$records = mysql_select($sectionname);
foreach ($records as $record) {
//turn field into an array of values
$tags = explode(",", @$record[$fieldName]);
// add tags to the count array
foreach ($tags as $tag) {
$tag = trim($tag);
if (!$tag) { continue; } // skip empty array values
if (array_key_exists($tag, $tagsToCount)) {
$tagsToCount[$tag]++;
}
else {
$tagsToCount[$tag] = 0;
}
}
}
}
At the end of this code, you'll have an array called $tagsToCount where the index of an array element is the tag and the value is the number of times it appeared.
At the end of this you can use this code:
showme($tagsToCount);
to view the structure of the array.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/