I couldn't see the point in a separate tags table, so I have a tags
column on the table that requires it.
To retrieve the tags and tag count, I do this:
function getTagsWithCounts($conditions = array())
{
// Return assoc_array(tags) for all records in
database. Keyed on tagword,
// value = tagcount
$tagCounts = array();
$tagRows = $this->findAll($conditions, 'tags');
foreach ($tagRows as $row):
$tags = explode(',',$row['Event']['tags']);
foreach ($tags as $tag):
$tag = trim($tag);
if (array_key_exists($tag, $tagCounts)):
$tagCounts[$tag]++;
else:
$tagCounts[$tag] = 1;
endif;
endforeach;
endforeach;
return $tagCounts;
}
It's simple and it is working on two commercial sites, soon to be four.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---