Place blocklayered (filter block) to the to the top of product list

1) modules/blocklayered/blocklayerd.php ... add na new funkction:

public function hookDisplayCategoryTop($params)
{
return $this->generateFiltersBlock($this->getSelectedFilters());
}

 

2) /override/controllers/front

create a file named CategoryController.php

class CategoryController  extends CategoryControllerCore
{

}

 

find the same file in the /controllers/front folder and copy the complete function initContent() from the /controllers/front/CategoryController.php into /override/controllers/front/CategoryController.php into

modify the beginning of the initContent() function by adding several lines:

public function initContent()
{

FrontController::initContent();
$instance = Module::getInstanceByName('blocklayered');
$params=array();
$filters= $instance->hookDisplayCategoryTop($params);

$this->context->smarty->assign(array(
'HOOK_CATEGORY_TOP' => $filters,
));

$this->setTemplate(_PS_THEME_DIR_.'category.tpl');
......
.....

}

 

3) edit the category.tpl file located in your theme folder. Place

 {$HOOK_CATEGORY_TOP} 

at the desired position of category.tpl file.

The file is located in the /themes/yourtheme/modules/blocklayered. If not present, create the folder and copy the file from the blocklayered module folder.

4) style filter block to alter its appearance. You will need css knowledge for proper styling, but as a quick start just append this code to the end of the blocklayered.css:

#layered_block_left div.filtr_type_weight, #layered_block_left div.filtr_type_price {
float: left;
width: 50%;
}
#layered_block_left div.filtr_type_manufacturer li {
float: left;
height: 18px;
width: 25%;
}

the file blocklayered.css is located in /themes/yourtheme/css/modules/blocklayered. If not present, create the folder and copy the file from the blocklayered module folder.

 

 

NOTE: it is possible to use a real displayCategoryTop hook, add it into blocklayered install() and call it in the CategoryController init() method: $filters=Hook::exec('displayCategoryTop');

 

webdnes.cz
®2016