[-] MO : #PSCFV-3223 - Fix bug with blocktags module
This commit is contained in:
@@ -36,7 +36,7 @@ class BlockTags extends Module
|
|||||||
{
|
{
|
||||||
$this->name = 'blocktags';
|
$this->name = 'blocktags';
|
||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
$this->version = 1.0;
|
$this->version = '1.1';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
|
||||||
@@ -96,16 +96,32 @@ class BlockTags extends Module
|
|||||||
* @param array $params Parameters
|
* @param array $params Parameters
|
||||||
* @return string Content
|
* @return string Content
|
||||||
*
|
*
|
||||||
* @todo Links on tags (dedicated page or search ?)
|
|
||||||
*/
|
*/
|
||||||
function hookLeftColumn($params)
|
function hookLeftColumn($params)
|
||||||
{
|
{
|
||||||
|
|
||||||
$tags = Tag::getMainTags((int)($params['cookie']->id_lang), (int)(Configuration::get('BLOCKTAGS_NBR')));
|
$tags = Tag::getMainTags((int)($params['cookie']->id_lang), (int)(Configuration::get('BLOCKTAGS_NBR')));
|
||||||
|
|
||||||
|
$max = -1;
|
||||||
|
$min = -1;
|
||||||
|
foreach ($tags as $tag)
|
||||||
|
{
|
||||||
|
if ($tag['times'] > $max)
|
||||||
|
$max = $tag['times'];
|
||||||
|
if ($tag['times'] < $min || $min == -1)
|
||||||
|
$min = $tag['times'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($min == $max)
|
||||||
|
$coef = $max;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$coef = (BLOCKTAGS_MAX_LEVEL - 1) / ($max - $min);
|
||||||
|
}
|
||||||
|
|
||||||
if (!sizeof($tags))
|
if (!sizeof($tags))
|
||||||
return false;
|
return false;
|
||||||
foreach ($tags AS &$tag)
|
foreach ($tags AS &$tag)
|
||||||
$tag['class'] = 'tag_level'.($tag['times'] > BLOCKTAGS_MAX_LEVEL ? BLOCKTAGS_MAX_LEVEL : $tag['times']);
|
$tag['class'] = 'tag_level'.(int)(($tag['times'] - $min) * $coef + 1);
|
||||||
$this->smarty->assign('tags', $tags);
|
$this->smarty->assign('tags', $tags);
|
||||||
|
|
||||||
return $this->display(__FILE__, 'blocktags.tpl');
|
return $this->display(__FILE__, 'blocktags.tpl');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module>
|
<module>
|
||||||
<name>blocktags</name>
|
<name>blocktags</name>
|
||||||
<displayName><![CDATA[Tags block]]></displayName>
|
<displayName><![CDATA[Tags block]]></displayName>
|
||||||
<version><![CDATA[1]]></version>
|
<version><![CDATA[1.1]]></version>
|
||||||
<description><![CDATA[Adds a block containing a tag cloud.]]></description>
|
<description><![CDATA[Adds a block containing a tag cloud.]]></description>
|
||||||
<author><![CDATA[PrestaShop]]></author>
|
<author><![CDATA[PrestaShop]]></author>
|
||||||
<tab><![CDATA[front_office_features]]></tab>
|
<tab><![CDATA[front_office_features]]></tab>
|
||||||
|
|||||||
Reference in New Issue
Block a user