Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

[*] blockcategories: set max depth for footer part separately #11

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions blockcategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function install()
!$this->registerHook('actionAdminLanguagesControllerStatusBefore') ||
!$this->registerHook('displayBackOfficeCategory') ||
!Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 4) ||
!Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH_FOOTER', 4) ||
!Configuration::updateValue('BLOCK_CATEG_DHTML', 1) ||
!Configuration::updateValue('BLOCK_CATEG_ROOT_CATEGORY', 1))
return false;
Expand All @@ -88,6 +89,7 @@ public function uninstall()

if (!parent::uninstall() ||
!Configuration::deleteByName('BLOCK_CATEG_MAX_DEPTH') ||
!Configuration::deleteByName('BLOCK_CATEG_MAX_DEPTH_FOOTER') ||
!Configuration::deleteByName('BLOCK_CATEG_DHTML') ||
!Configuration::deleteByName('BLOCK_CATEG_ROOT_CATEGORY'))
return false;
Expand All @@ -100,6 +102,7 @@ public function getContent()
if (Tools::isSubmit('submitBlockCategories'))
{
$maxDepth = (int)(Tools::getValue('BLOCK_CATEG_MAX_DEPTH'));
$maxDepthFooter = (int)(Tools::getValue('BLOCK_CATEG_MAX_DEPTH_FOOTER'));
$dhtml = Tools::getValue('BLOCK_CATEG_DHTML');
$nbrColumns = Tools::getValue('BLOCK_CATEG_NBR_COLUMN_FOOTER', 4);
if ($maxDepth < 0)
Expand All @@ -109,6 +112,7 @@ public function getContent()
else
{
Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', (int)$maxDepth);
Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH_FOOTER', (int)$maxDepthFooter);
Configuration::updateValue('BLOCK_CATEG_DHTML', (int)$dhtml);
Configuration::updateValue('BLOCK_CATEG_NBR_COLUMN_FOOTER', (int)$nbrColumns);
Configuration::updateValue('BLOCK_CATEG_SORT_WAY', Tools::getValue('BLOCK_CATEG_SORT_WAY'));
Expand Down Expand Up @@ -283,7 +287,7 @@ public function hookFooter($params)
$this->setLastVisitedCategory();
if (!$this->isCached('blockcategories_footer.tpl', $this->getCacheId()))
{
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH_FOOTER');
// Get all groups for this customer and concatenate them as a string: "1,2,3..."
$groups = implode(', ', Customer::getGroupsStatic((int)$this->context->customer->id));
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
Expand Down Expand Up @@ -314,7 +318,7 @@ public function hookFooter($params)
$this->smarty->assign('numberColumn', $numberColumn);
$this->smarty->assign('widthColumn', $widthColumn);

$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'));
$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH_FOOTER'));
unset($resultParents, $resultIds);

$isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);
Expand Down Expand Up @@ -415,6 +419,12 @@ public function renderForm()
'name' => 'BLOCK_CATEG_MAX_DEPTH',
'desc' => $this->l('Set the maximum depth of category sublevels displayed in this block (0 = infinite).'),
),
array(
'type' => 'text',
'label' => $this->l('Maximum depth for footer'),
'name' => 'BLOCK_CATEG_MAX_DEPTH_FOOTER',
'desc' => $this->l('Set the maximum depth of category sublevels displayed in this block in footer (0 = infinite).'),
),
array(
'type' => 'switch',
'label' => $this->l('Dynamic'),
Expand Down Expand Up @@ -502,6 +512,7 @@ public function getConfigFieldsValues()
{
return array(
'BLOCK_CATEG_MAX_DEPTH' => Tools::getValue('BLOCK_CATEG_MAX_DEPTH', Configuration::get('BLOCK_CATEG_MAX_DEPTH')),
'BLOCK_CATEG_MAX_DEPTH_FOOTER' => Tools::getValue('BLOCK_CATEG_MAX_DEPTH_FOOTER', Configuration::get('BLOCK_CATEG_MAX_DEPTH_FOOTER')),
'BLOCK_CATEG_DHTML' => Tools::getValue('BLOCK_CATEG_DHTML', Configuration::get('BLOCK_CATEG_DHTML')),
'BLOCK_CATEG_NBR_COLUMN_FOOTER' => Tools::getValue('BLOCK_CATEG_NBR_COLUMN_FOOTER', Configuration::get('BLOCK_CATEG_NBR_COLUMN_FOOTER')),
'BLOCK_CATEG_SORT_WAY' => Tools::getValue('BLOCK_CATEG_SORT_WAY', Configuration::get('BLOCK_CATEG_SORT_WAY')),
Expand Down