[*] BO : Added category tree to product list

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12537 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2012-01-18 15:49:06 +00:00
parent 853c54aa48
commit 93214648e9
4 changed files with 65 additions and 45 deletions
@@ -30,24 +30,41 @@
{if isset($category_tree)}
<script type="text/javascript">
$(document).ready(function(){
$('#go_to_categ').bind('change', function(){
var base_url = '{$base_url}';
var base_url = '{$base_url}';
// Load category products page when category is clicked
$('#categories-treeview :input').live('click', function(){
if (this.value !== "")
location.href = base_url + '&id_category=' + parseInt(this.value);
else
location.href = base_url;
});
// Make sure the checkbox is checked/unchecked when the link is clicked
$('#toggle_category_tree').bind('click', function(){
$('#block_category_tree').toggle();
if ($('#block_category_tree').is(':visible'))
$(this).find('input').attr('checked', 'checked');
else
{
$(this).find('input').removeAttr('checked');
location.href = base_url;
}
});
});
</script>
<div class="bloc-leadin">
{l s='Go to category:'}
<select id="go_to_categ" name="go_to_categ">
{foreach from=$category_tree item=categ}
<option value="{$categ->id}" {if $categ->selected}selected="selected"{/if} >
{$categ->dashes}{$categ->name}
</option>
{/foreach}
</select>
<div id="container_category_tree">
<a href="#" id="toggle_category_tree">
<form>
<input type="checkbox" {if $is_category_filter}checked="checked"{/if} />{l s='Filter by category'}
</form>
</a>
<div id="block_category_tree" {if !$is_category_filter}style="display:none"{/if}>
<br />
{$category_tree}
</div>
</div>
</div>
{/if}
{/block}
-3
View File
@@ -1431,10 +1431,8 @@ class AdminControllerCore extends Controller
$helper = new HelperList();
$this->setHelperDisplay($helper);
$this->tpl_list_vars['img_dir'] = 'toto';
$helper->tpl_vars = $this->tpl_list_vars;
$helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
// Check if list templates have been overriden
// For compatibility reasons, we have to check standard actions in class attributes
foreach ($this->actions_available as $action)
@@ -1538,7 +1536,6 @@ class AdminControllerCore extends Controller
// @todo : move that in Helper
$helper->title = $this->toolbar_title;
$helper->toolbar_btn = $this->toolbar_btn;
$helper->show_toolbar = $this->show_toolbar;
$helper->toolbar_fix = $this->toolbar_fix;
$helper->override_folder = $this->tpl_folder;
+24 -32
View File
@@ -1884,40 +1884,31 @@ class AdminProductsControllerCore extends AdminController
self::$currentIndex .= '&id_category='.$id_category;
$this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true));
if (!empty($this->_list))
$id_category = Tools::getValue('id_category', 1);
$root_category = Category::getRootCategory();
if (!$root_category->id_category)
{
$id_category = Tools::getValue('id_category', 1);
if (!$id_category)
$id_category = 1;
// @todo lot of ergonomy works around here
// @todo : move blockcategories select queries in class Category
$root_categ = Category::getRootCategory();
$children = $root_categ->getAllChildren();
$category_tree = array();
// Add category "all products" to tree
$all_categ = new Category();
$all_categ->name = 'All products';
$all_categ->selected = $this->_category->id_category == $all_categ->id;
$all_categ->dashes = '';
$category_tree[] = $all_categ;
// Add root category to tree
$root_categ->selected = $this->_category->id_category == $root_categ->id;
$root_categ->dashes = str_repeat('&nbsp;-&nbsp;',$root_categ->level_depth);
$category_tree[] = $root_categ;
foreach ($children as $categ)
{
$categ->selected = $this->_category->id_category == $categ->id;
$categ->dashes = str_repeat('&nbsp;-&nbsp;',$categ->level_depth);
$category_tree[] = $categ;
}
$this->tpl_list_vars['category_tree'] = $category_tree;
// used to build the new url when changing category
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
$root_category->id_category = 0;
$root_category->name = $this->l('Root');
}
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
$translations = array(
'Root' => $root_category,
'selected' => $this->l('selected'),
'Collapse All' => $this->l('Collapse All'),
'Expand All' => $this->l('Expand All'),
'Check All' => $this->l('Check All'),
'Uncheck All' => $this->l('Uncheck All'),
'search' => $this->l('Search a category')
);
$this->tpl_list_vars['is_category_filter'] = Tools::getValue('id_category') ? true : false;
$this->tpl_list_vars['category_tree'] = Helper::renderAdminCategorieTree($translations, array($id_category), 'categoryBox', true, false);
// used to build the new url when changing category
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
}
// @todo module free
$this->tpl_form_vars['vat_number'] = file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php');
@@ -1932,6 +1923,7 @@ class AdminProductsControllerCore extends AdminController
if (!Tools::getValue('id_category'))
unset($this->fieldsDisplay['position']);
return parent::renderList();
}
+14
View File
@@ -2243,4 +2243,18 @@ margin-bottom:7px;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
width: 300px;
}
#container_category_tree {
border: 1px solid #ccc;
border-radius: 3px;
padding: 5px;
}
#container_category_tree a{
font-weight: bold;
}
#container_category_tree a input{
margin-right: 3px;
}