Archive for October, 2007
How to get tags cloud from the database?
_sqls package:
function getTagsCloud( $oModel ){
$sSql = “SELECT
COUNT(tag_id) as quantity, tag_id, tag_name
FROM fa_tags
WHERE tag_key=”.EVENT_KEY.” GROUP BY tag_name ORDER BY tag_name LIMIT 0,30 “;
parent::execute_query($sSql, __LINE__, __FILE__);
}
_models package:
function getTagsCloud(){
$this->oDb->getTagsCloud( $this );
return $this->oDb;
}
_views package:
function showTagsCloud( $oModel ){
$mRes = $oModel->getTagsCloud();
$aTags = array();
$aTagIds = array();
while ( $aRows = $mRes->fetch_row() ){
$aTags[strtolower($aRows[tag_name])] = $aRows[quantity];
$aTagIds[$aRows[quantity]] = $aRows[tag_id];
}
// change these font sizes if you will
$iMaxSize = 150; // max font size in %
$iMinSize = 100; // min font size in %
// get the largest and smallest array values
$iMaxQty = max(array_values($aTags));
$iMinQty = min(array_values($aTags));
// find the range of values
$spread = $iMaxQty – $iMinQty;
if ($iSpread == 0) { // divide by zero
$iSpread = 1;
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$iStep = ($iMaxSize – $iMinSize)/($iSpread);
// loop through our tag array
foreach ($aTags as $sKey => $iValue) {
// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$aTag[tag_size] = $iMinSize + (($iValue – $iMinQty) * $iStep);
$aTag[tag_name] = $sKey;
$aTag[href] = $this->oUrlPattern->assignItem(‘event’, ‘tags’, array(“tag_name” => $aTag[tag_name]) );
$this->oTPL->assign(“PopularTags”, $aTag);
$this->oTPL->parse(“GLOBAL.PopularTags”);
}
}
Giao diện mới của công ty (bản demo)
Em mới thiết kế lại giao diện của trang chủ mong mọi người xem xét và cho ý kiến.



