view/frontend/templates/layer/view.phtml
<?php
/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
* @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\Filter;
use Tweakwise\Magento2Tweakwise\Model\NavigationConfig;
use Magento\LayeredNavigation\Block\Navigation;
/**
* @var $block Navigation
* phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
if (!$block->canShowBlock()) return;
?>
<?php $filters = $block->getFilters(); /** @var $filters Filter[] */ ?>
<?php /** @var NavigationConfig $tweakwiseNavigationConfig */?>
<?php $tweakwiseNavigationConfig = $block->getData('tweakwise_navigation_config');?>
<?php $jsFormConfig = $tweakwiseNavigationConfig->getJsFormConfig(); ?>
<?php $renderFilterButton = $tweakwiseNavigationConfig->isFormFilters();?>
<?php $hasFilters = count($filters) > 0; ?>
<div class="block filter<?=(!$hasFilters ? ' filter-no-options' : '')?>"
id="layered-filter-block"
data-mage-init='{"collapsible":{"openedState": "active", "collapsible": true, "active": false, "collateral": { "openedState": "filter-active", "element": "body" } }}'>
<?php $filtered = count($block->getLayer()->getState()->getFilters()) ?>
<div class="block-title filter-title" data-count="<?=$filtered?>">
<strong data-role="title"><?=__('Shop By')?></strong>
</div>
<div class="block-content filter-content">
<form id="facet-filter-form" <?=($jsFormConfig ? sprintf('data-mage-init=\'%s\'', $jsFormConfig) : '')?>>
<?=$block->getChildHtml('state');?>
<?php if ($block->getLayer()->getState()->getFilters()): ?>
<div class="block-actions filter-actions">
<a href="<?=$escaper->escapeUrl($block->getClearUrl()) ?>" class="action clear filter-clear"><span><?=__('Clear All')?></span></a>
</div>
<?php endif; ?>
<?php if ($hasFilters): ?>
<strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?=__('Shopping Options') ?></strong>
<div class="filter-options" id="narrow-by-list" data-role="content">
<?php foreach ($tweakwiseNavigationConfig->getFilterFormInput() as $name => $value):?>
<?php // These are tweakwise system parameters which are needed for ajax navigation ?>
<input type="hidden" name="<?=$name?>" value="<?=$value?>">
<?php endforeach;?>
<?php foreach ($filters as $filter): ?>
<?php if ($filter->isCollapsible()): ?>
<?php $filterActive = $filter->isDefaultCollapsed() ? 'false' : '[0]'; ?>
<div class="collapsible-container <?=$filter->getCssClass()?>"
data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": <?=$filterActive?>}}'
>
<div data-role="collapsible" class="filter-options-item">
<div data-role="title" class="filter-options-title">
<?=__($filter->getName())?>
<?php $tooltip = $filter->getTooltip(); ?>
<?php if ($tooltip): ?>
<?php $tooltip = htmlentities($tooltip); ?>
<span class="tooltip" data-tooltip="<?=$tooltip?>"><span>i</span></span>
<?php endif; ?>
</div>
<?php $filterContentStyle = $filter->isDefaultCollapsed() ? ' style="display: none;"' : ''?>
<div data-role="content" class="filter-options-content"<?=$filterContentStyle?>>
<?=$block->getChildBlock('renderer')->render($filter) ?>
</div>
</div>
</div>
<?php else: ?>
<div class="filter-options-item">
<div class="filter-options-title filter-options-title-non-collapsible"><?=__($filter->getName())?></div>
<div class="filter-options-content">
<?=$block->getChildBlock('renderer')->render($filter) ?>
</div>
</div>
<?php endif; ?>
<?php if ($renderFilterButton): ?>
<div class="show-items-link">
<button type="button" class="btn btn-primary btn-block js-btn-filter"><?=__(sprintf('Show <span>%s</span> items', $block->getLayer()->getProductCount())); ?></button>
</div>
<?php endif;?>
<?php endforeach; ?>
</div>
<?php endif; ?>
</form>
</div>
</div>