From f20fa55308f34fd3a61520584d8a1e317817a0bd Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Fri, 13 Sep 2013 09:49:07 +0200 Subject: [PATCH] // Fix filter by category checkbox --- .../products/helpers/list/list_header.tpl | 10 +- .../products/helpers/tree/tree_categories.tpl | 118 ++++++++++++++++++ .../products/helpers/tree/tree_header.tpl | 42 +++++++ .../products/helpers/tree/tree_toolbar.tpl | 25 ++++ classes/tree/Tree.php | 8 +- controllers/admin/AdminProductsController.php | 4 +- 6 files changed, 193 insertions(+), 14 deletions(-) create mode 100644 admin-dev/themes/default/template/controllers/products/helpers/tree/tree_categories.tpl create mode 100644 admin-dev/themes/default/template/controllers/products/helpers/tree/tree_header.tpl create mode 100644 admin-dev/themes/default/template/controllers/products/helpers/tree/tree_toolbar.tpl diff --git a/admin-dev/themes/default/template/controllers/products/helpers/list/list_header.tpl b/admin-dev/themes/default/template/controllers/products/helpers/list/list_header.tpl index 6b51a87aa..0d317eabc 100644 --- a/admin-dev/themes/default/template/controllers/products/helpers/list/list_header.tpl +++ b/admin-dev/themes/default/template/controllers/products/helpers/list/list_header.tpl @@ -53,15 +53,7 @@
- -
- - {l s='Filter by category'} -
-
-
- {$category_tree} -
+ {$category_tree}
{/if} diff --git a/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_categories.tpl b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_categories.tpl new file mode 100644 index 000000000..78f662c03 --- /dev/null +++ b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_categories.tpl @@ -0,0 +1,118 @@ +{* +* 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 +* @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 +*} +
+ {if isset($header)}{$header}{/if} + +
+ \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_header.tpl b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_header.tpl new file mode 100644 index 000000000..0271ca921 --- /dev/null +++ b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_header.tpl @@ -0,0 +1,42 @@ +{* +* 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 +* @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 +*} + +
+   {l s=$title} + +
\ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_toolbar.tpl b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_toolbar.tpl new file mode 100644 index 000000000..befb4815d --- /dev/null +++ b/admin-dev/themes/default/template/controllers/products/helpers/tree/tree_toolbar.tpl @@ -0,0 +1,25 @@ +{* +* 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 +* @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 +*} +{if isset($actions)}{foreach from=$actions item=action}{$action->render()}{/foreach}{/if} \ No newline at end of file diff --git a/classes/tree/Tree.php b/classes/tree/Tree.php index a4bc77f45..95b82f13c 100644 --- a/classes/tree/Tree.php +++ b/classes/tree/Tree.php @@ -329,7 +329,8 @@ class TreeCore $this->getTemplateFile($this->getHeaderTemplate()), $this->getContext()->smarty ); - $headerTemplate->assign(array( + $headerTemplate->assign($this->getAttributes()) + ->assign(array( 'title' => $this->getTitle(), 'toolbar' => $this->useToolbar() ? $this->renderToolbar() : null )); @@ -337,9 +338,8 @@ class TreeCore } //Assign Tree nodes - $template - ->assign($this->getAttributes()) - ->assign(array( + $template->assign($this->getAttributes()) + ->assign(array( 'id' => $this->getId(), 'nodes' => $this->renderNodes($data) )); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 7b1affd68..ce7304fc6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2310,7 +2310,9 @@ class AdminProductsControllerCore extends AdminController // Generate category selection tree $tree = new HelperTreeCategories('categories-tree', 'Filter by category'); - $tree->setSelectedCategories(array((int)$id_category)); + $tree->setAttribute('is_category_filter', (bool)$this->id_current_category) + ->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token) + ->setSelectedCategories(array((int)$id_category)); $this->tpl_list_vars['category_tree'] = $tree->render(); // used to build the new url when changing category