Jump to content

blocktags fix


caparuni

Recommended Posts

last night when take closed look on block tags module, i found out that this module maybe need a little fix

blocktags.php (original)

function hookLeftColumn($params)
   {
       global $smarty;

       $tags = Tag::getMainTags(intval($params['cookie']->id_lang), intval(Configuration::get('BLOCKTAGS_NBR')));
       if (!sizeof($tags))
           return '';
       $maxFontSize = 18;
       $minFontSize = 10;
       $maxNumber = intval($tags[0]['times']);
       $classPrefix = 'tag_level';
       for ($i = 0; $i < sizeof($tags); ++$i)
       {
           $tags[$i]['fontSize'] = floor(($maxFontSize * $tags[$i]['times']) / $maxNumber);
           if ($tags[$i]['fontSize'] < $minFontSize)
               $tags[$i]['fontSize'] = $minFontSize;
           // 2nd version: use CSS class
           $tags[$i]['class'] = $classPrefix.$tags[$i]['times'];
           if ($tags[$i]['times'] > 3)
               $tags[$i]['class'] = $classPrefix;
       }
       $smarty->assign('tags', $tags);
       return $this->display(__FILE__, 'blocktags.tpl');
   }



change it to

function hookLeftColumn($params)
   {
       global $smarty;

       $tags = Tag::getMainTags(intval($params['cookie']->id_lang), intval(Configuration::get('BLOCKTAGS_NBR')));
       if (!sizeof($tags))
           return '';
       $maxLevel = 3;
       $minLevel = 1;
       $classPrefix = 'tag_level';
       for ($i = 0; $i < sizeof($tags); ++$i)
       {
           $tags[$i]['class'] = $classPrefix.mt_rand($minLevel,$maxLevel);
       }
       $smarty->assign('tags', $tags);
       return $this->display(__FILE__, 'blocktags.tpl');
   }



since in blocktags.tpl only use css class to define font size, so i remove all thing related to $tags[$i]['fontSize'] such as $maxFontSize, $minFontSize, $maxNumber etc...
well thats it, now we get smaller and simplify block tags with a random font size handled by css

;)


ps: if u want to made random tags just read my old post

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...