new rendering of cumulative filter
Closed this issue · 3 comments
arboc commented
new feature / enhancement of the cumulative filter:
- Display the categories and subcategories in a hierarchical way.
- Add a checkbox in front of each entry
(un-) select the checkboxes changes the filter.
this maybe another solution for #173
fritzmg commented
I am in favor of this :). I already implemented this in one project, sort of:
// src/FrontendModule/CumulativeFilterModule.php
namespace App\FrontendModule;
use Contao\CoreBundle\Exception\RedirectResponseException;
class CumulativeFilterModule extends \Codefog\NewsCategoriesBundle\FrontendModule\CumulativeFilterModule
{
protected function compile(): void
{
parent::compile();
$inactiveCategories = $this->getInactiveCategories();
$ids = [];
if (null !== $this->activeCategories) {
$ids = $this->activeCategories->fetchEach('id');
}
if (null !== $inactiveCategories) {
$ids = array_merge($ids, $inactiveCategories->fetchEach('id'));
}
$this->Template->categories = $this->renderNewsCategories((int) $this->news_categoriesRoot, \array_unique($ids));
}
protected function getActiveCategories(array $customCategories = [])
{
try {
return parent::getActiveCategories($customCategories);
} catch (RedirectResponseException $e) {
return null;
}
}
}
<!-- templates/mod_newscategories_cumulative.html5 -->
<?php $this->extend('block_unsearchable'); ?>
<?php $this->block('content'); ?>
<?= $this->categories ?>
<?php $this->endblock(); ?>
qzminski commented
Pull requests are welcome 😉
qzminski commented
Released in 3.4.0.