caparuni Posted April 3, 2009 Share Posted April 3, 2009 bikin blok tag jadi random tiap kali load page.edit .../classes/Tag.php (sekitar line 111)cari : ORDER BY times DESC ganti dengan : ORDER BY RAND() oia secara default, tag hanya di tampilkan sebanyak 10, nah kalo mo ubah jumlah tag yg tampil,edit .../modules/blocktags/blocktags.php (skitar line 35)cari : $tags = Tag::getMainTags(intval($params['cookie']->id_lang)); ganti dengan : $tags = Tag::getMainTags(intval($params['cookie']->id_lang),25); dmn 25 adalah jumpah tag yg akan di tampilkan. nah ganti suka2 lu :: semoga berguna :: Link to comment Share on other sites More sharing options...
Ardian Yuli Setyanto Posted April 3, 2009 Share Posted April 3, 2009 Thanks dah share. Tapi kalau mau lebih advance lagi, seharusnya bisa di order berdasar jumlah produk dari tag tersebut. font size nya juga menyesuaikan. semisal tag widget di wordpress. Link to comment Share on other sites More sharing options...
caparuni Posted April 4, 2009 Author Share Posted April 4, 2009 font nya otomatis besar-kecil kok Link to comment Share on other sites More sharing options...
WODP Posted April 5, 2009 Share Posted April 5, 2009 If i change code how you described, i get empty Tags block....Any ideas?Thanks,W. Link to comment Share on other sites More sharing options...
caparuni Posted April 5, 2009 Author Share Posted April 5, 2009 are u sure u already input the tag for the product? to make sure please check directly to sql, since theres no menu about tag in back-office (cmimw).please check ps_tag & ps_product_tag in sql Link to comment Share on other sites More sharing options...
WODP Posted April 5, 2009 Share Posted April 5, 2009 Yes, i have, becouse it shows in tag block.You can check here: www.mojprostor.net on the lower right corner.But those tags don't show random. I wanted them to be random, but i have changed in Tag.php and blocktags.php as you described. Anything else? I hope i understood correct your instructions Thanks,W. Link to comment Share on other sites More sharing options...
caparuni Posted April 5, 2009 Author Share Posted April 5, 2009 hmmm... this is my .../classes/Tag.php static public function getMainTags($id_lang, $nb = 10) { return Db::getInstance()->ExecuteS(' SELECT t.name, COUNT(pt.id_tag) AS times FROM `'._DB_PREFIX_.'product_tag` pt LEFT JOIN `'._DB_PREFIX_.'tag` t ON t.id_tag = pt.id_tag LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = pt.id_product WHERE id_lang = '.intval($id_lang).' AND p.active = 1 GROUP BY t.id_tag ORDER BY RAND() LIMIT 0, '.intval($nb)); } see the RAND( )this is my .../modules/blocktags/blocktags.php function hookLeftColumn($params) { global $smarty; $tags = Tag::getMainTags(intval($params['cookie']->id_lang),25); if (!sizeof($tags)) return ''; $maxFontSize = 16; $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'); } Link to comment Share on other sites More sharing options...
caparuni Posted April 5, 2009 Author Share Posted April 5, 2009 btw, try to delete all files under .../tools/smarty/compile Link to comment Share on other sites More sharing options...
WODP Posted April 5, 2009 Share Posted April 5, 2009 THANKS, now it works!!! i needed to change whole section.Much appreciated!!W.edit: didn't need to delete anything... Link to comment Share on other sites More sharing options...
caparuni Posted April 5, 2009 Author Share Posted April 5, 2009 yw, glad can help Link to comment Share on other sites More sharing options...
Денис Posted January 29, 2010 Share Posted January 29, 2010 Sorry, but I don't understand why it need codein /modules/blocktags/blocktags.php if ($tags[$i]['times'] > 3) $tags[$i]['class'] = $classPrefix; if all tags are lagger than 3, they view the smallest I don't find in /modules/blocktags/blocktags.tpl any {$tag.fontSize}I'm try: function hookLeftColumn($params) { global $smarty; $numberTags = intval(Configuration::get('BLOCKTAGS_NBR')); $tags = Tag::getMainTags(intval($params['cookie']->id_lang), $numberTags); if (!sizeof($tags)) return ''; $maxFontSize = 18; $minFontSize = 10; $maxNumber = intval($tags[0]['times']); /* In /classes/Tag.php method getMainTags() order in SQL must be ORDER BY times DESC */ $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; $tagClass = floor(($tags[$i]['times']) / $maxNumber) + 1; if($tagClass > 5) $tagClass = 5; $tags[$i]['class'] = $classPrefix.$tagClass; } $smarty->assign('tags', $tags); return $this->display(__FILE__, 'blocktags.tpl'); } and change in global.css a.tag_level5 { font-size: 1.8em; font-weight:bold;} a.tag_level4 { font-size: 1.6em; font-weight:bold;} a.tag_level3 { font-size: 1.4em;} a.tag_level2 { font-size: 1.2em;} a.tag_level1 { font-size: 1em; color:#888!important;} and tags view correct! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now