// Add top menu to blockcategories
This commit is contained in:
@@ -67,6 +67,7 @@ class BlockCategories extends Module
|
||||
!$this->registerHook('actionAdminMetaControllerUpdate_optionsBefore') ||
|
||||
!$this->registerHook('actionAdminLanguagesControllerStatusBefore') ||
|
||||
!$this->registerHook('displayBackOfficeCategory') ||
|
||||
!$this->registerHook('displayTop') ||
|
||||
!Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 4) ||
|
||||
!Configuration::updateValue('BLOCK_CATEG_DHTML', 1))
|
||||
return false;
|
||||
@@ -129,13 +130,28 @@ class BlockCategories extends Module
|
||||
|
||||
if (!isset($resultIds[$id_category]))
|
||||
return false;
|
||||
|
||||
$thumbnails = array();
|
||||
|
||||
if ($currentDepth == 0)
|
||||
{
|
||||
$files = scandir(_PS_CAT_IMG_DIR_);
|
||||
|
||||
foreach ($files as $file)
|
||||
if (preg_match('/'.$id_category.'-([0-9])?_thumb.jpg/i', $file) === 1)
|
||||
$thumbnails[] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_.$file, 'category_'.$file, 100, 'jpg', true, true);
|
||||
|
||||
}
|
||||
|
||||
$return = array(
|
||||
'id' => $id_category,
|
||||
'link' => $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),
|
||||
'name' => $resultIds[$id_category]['name'],
|
||||
'desc'=> $resultIds[$id_category]['description'],
|
||||
'children' => $children
|
||||
'children' => $children,
|
||||
'thumbnails' => $thumbnails
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -165,6 +181,13 @@ class BlockCategories extends Module
|
||||
return $this->display(__FILE__, 'views/blockcategories_admin.tpl');
|
||||
}
|
||||
|
||||
public function hookDisplayTop($params)
|
||||
{
|
||||
$params['is_top_menu'] = true;
|
||||
$this->smarty->assign('numberColumn', 3);
|
||||
return $this->hookLeftColumn($params);
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
{
|
||||
$category = false;
|
||||
@@ -181,7 +204,7 @@ class BlockCategories extends Module
|
||||
}
|
||||
|
||||
$cacheId = $this->getCacheId($category ? $category->id : null);
|
||||
if (!$this->isCached('blockcategories.tpl', $cacheId))
|
||||
if (!$this->isCached('blockcategories'.((isset($params['is_top_menu']) && $params['is_top_menu']) ? '_top' : '').'.tpl', $cacheId))
|
||||
{
|
||||
$range = '';
|
||||
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
|
||||
@@ -227,7 +250,7 @@ class BlockCategories extends Module
|
||||
else
|
||||
$this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
|
||||
}
|
||||
return $this->display(__FILE__, 'blockcategories.tpl', $cacheId);
|
||||
return $this->display(__FILE__, 'blockcategories'.((isset($params['is_top_menu']) && $params['is_top_menu']) ? '_top' : '').'.tpl', $cacheId);
|
||||
}
|
||||
|
||||
protected function getCacheId($name = null)
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
{*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<!-- Block categories module -->
|
||||
<div id="categories_block_top">
|
||||
<div class="category_top">
|
||||
<div class="list">
|
||||
<ul class="tree {if $isDhtml}dhtml{/if} sf-menu sf-js-enabled clearfix">
|
||||
|
||||
{foreach from=$blockCategTree.children item=child name=blockCategTree}
|
||||
|
||||
{if $smarty.foreach.blockCategTree.last}
|
||||
{include file="$branche_tpl_path" node=$child last='true'}
|
||||
{else}
|
||||
{include file="$branche_tpl_path" node=$child}
|
||||
{/if}
|
||||
|
||||
{if isset($blockCategTree.thumbnails) && $blockCategTree.thumbnails|count > 0}
|
||||
<div id="category-thumbnails">
|
||||
{foreach $blockCategTree.thumbnails as $thumbnail}
|
||||
<div>{$thumbnail}</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if ($smarty.foreach.blockCategTree.iteration mod $numberColumn) == 0 AND !$smarty.foreach.blockCategTree.last}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="category_footer" style="float:left;clear:none;width:{$widthColumn}%">
|
||||
<div style="float:left" class="list">
|
||||
<ul class="tree {if $isDhtml}dhtml{/if}">
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<!-- /Block categories module -->
|
||||
@@ -5,5 +5,5 @@ if (!defined('_PS_VERSION_'))
|
||||
|
||||
function upgrade_module_2_1($object)
|
||||
{
|
||||
return $object->registerHook('displayBackOfficeCategory');
|
||||
return ($object->registerHook('displayBackOfficeCategory') && $object->registerHook('displayTop'));
|
||||
}
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
{else}
|
||||
{include file="$branche_tpl_path" node=$child}
|
||||
{/if}
|
||||
|
||||
{if isset($blockCategTree.thumbnails) && $blockCategTree.thumbnails|count > 0}
|
||||
<div id="category-thumbnails">
|
||||
{foreach $blockCategTree.thumbnails as $thumbnail}
|
||||
<div>{$thumbnail}</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if ($smarty.foreach.blockCategTree.iteration mod $numberColumn) == 0 AND !$smarty.foreach.blockCategTree.last}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user