init
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
/* @var $block WeltPixel\LayeredNavigation\Block\Navigation\FilterRenderer */
|
||||
$attributeCode = $this->getAttribute()->getAttributeCode();
|
||||
|
||||
$url = '';
|
||||
?>
|
||||
|
||||
<?php $attributeId = $block->getAttributeId()?>
|
||||
<?php $isMulti = $block->getIsMultiselect()?>
|
||||
<?php $canShowQty = (is_null($block->getShowQty())) ? $this->helper('\Magento\Catalog\Helper\Data')->shouldDisplayProductCountOnLayer() : $block->getShowQty();?>
|
||||
<ol class="items" id="<?= $attributeId ?>_items" >
|
||||
<?php foreach ($filterItems as $index => $filterItem): ?>
|
||||
<?php /* @var $filterItem \Magento\Catalog\Model\Layer\Filter\Item */ ?>
|
||||
|
||||
<?php $filterUrl = $filterItem->getUrl(); ?>
|
||||
<?php $requestVar = $filterItem->getFilter()->getRequestVar();?>
|
||||
<?php $filterItemVal = is_array($filterItem->getValue()) ? implode('-', $filterItem->getValue()) : $filterItem->getValue()?>
|
||||
|
||||
<?php if (!$url && $filterItem->getCount() && $attributeCode=='category_option') { $url=$filterUrl; } ?>
|
||||
<?php $dataOptPath = ($requestVar != 'cat') ? $filterItem->getFilter()->getAttributeModel()->getAttributeCode() . '='. $filterItemVal : 'cat='.$filterItemVal;?>
|
||||
<li class="item" style="display: none" id="wp_ln_attr_<?= $attributeId ?>_<?= /* @escapeNotVerified */ is_array($filterItem->getValue()) ? implode('-', $filterItem->getValue()) : $filterItem->getValue() ?>">
|
||||
<a href="<?= $block->escapeUrl($filterUrl) ?>"
|
||||
data-opt-path="<?= /* @escapeNotVerified */ $block->escapeHtmlAttr($dataOptPath) ?>"
|
||||
data-is-multi="<?= $isMulti?>">
|
||||
<?= /* @escapeNotVerified */ $filterItem->getLabel() ?>
|
||||
<?php if ($canShowQty): ?>
|
||||
<span class="count"><?= /* @escapeNotVerified */ $filterItem->getCount() ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
<div class="wp-ln-actions">
|
||||
<b id="loadMore_<?=$attributeId?>" class="wp-ln-action wp-ln-load-more icon-line-arrow-down">Show More</b>
|
||||
<b id="showLess_<?=$attributeId?>" class="wp-ln-action wp-ln-show-less icon-line-arrow-up">Show Less</b>
|
||||
</div>
|
||||
</ol>
|
||||
<?php
|
||||
if ($url && $attributeCode=='category_option' && !$this->getRequest()->getParam('category_option')) {
|
||||
$block->setRedirectUrl($url);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
require(['jquery'], function($){
|
||||
$(document).ready(function(){
|
||||
var visibleItems = "<?= $block->getVisibleItems()?>",
|
||||
visibleItemsStep = "<?= $block->getVisibleItemsStep()?>",
|
||||
attrId = "<?= $attributeId?>",
|
||||
elId = attrId + '_items',
|
||||
ulSize = $('#' + elId + ' li').length,
|
||||
loadMoreId = '#loadMore_' + attrId,
|
||||
showLessId = '#showLess_' + attrId,
|
||||
x = parseInt(visibleItems),
|
||||
initialX = x,
|
||||
xStep = parseInt(visibleItemsStep);
|
||||
if(visibleItems > 0 && visibleItems.length > 0 && visibleItems < 99 && ulSize > visibleItems) {
|
||||
$(loadMoreId).show();
|
||||
$("#"+ elId + " li:lt(" + visibleItems + ")").show();
|
||||
$(showLessId).hide();
|
||||
} else {
|
||||
$("#"+ elId + " li").show();
|
||||
$(loadMoreId).hide();
|
||||
$(showLessId).hide();
|
||||
}
|
||||
|
||||
$(loadMoreId).click(function () {
|
||||
if(xStep == 99) {
|
||||
$('#' + elId + ' li:lt(' + ulSize + ')').show();
|
||||
$(this).hide();
|
||||
$(showLessId).show();
|
||||
} else {
|
||||
x = ( x + xStep <= ulSize) ? x + xStep : ulSize;
|
||||
$('#' + elId + ' li:lt(' + x + ')').show();
|
||||
if(ulSize == x){
|
||||
$(this).hide();
|
||||
$(showLessId).show();
|
||||
}else{
|
||||
$(showLessId).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(showLessId).click(function () {
|
||||
if(xStep == 99) {
|
||||
$('#' + elId + ' li').not(':lt(' + xStep + ')').hide();
|
||||
$(this).hide();
|
||||
$(loadMoreId).show();
|
||||
} else {
|
||||
x = ( x - xStep < 0 || x == ulSize) ? initialX : x - xStep;
|
||||
$('#' + elId + ' li').not(':lt(' + x + ')').hide();
|
||||
if(x <= visibleItems){
|
||||
$(this).hide();
|
||||
$(loadMoreId).show();
|
||||
}else{
|
||||
$(loadMoreId).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Category layered navigation state
|
||||
*
|
||||
* @var $block \WeltPixel\LayeredNavigation\Block\Navigation\State
|
||||
*/
|
||||
?>
|
||||
<?php $_filters = $block->getActiveFilters() ?>
|
||||
<?php if (!empty($_filters)): ?>
|
||||
<div class="filter-current" id="wp_ln_shopby">
|
||||
|
||||
<ol class="items" id="wp_ln_shopby_items" data-role="content">
|
||||
<?php foreach ($_filters as $_filter): ?>
|
||||
<?php
|
||||
$requestVar = $_filter->getFilter()->getRequestVar();
|
||||
$filterItemVal = (is_array($_filter->getValue())) ? implode('-', $_filter->getValue()) : $_filter->getValue();
|
||||
$dataAttrId = ($requestVar != 'cat') ? $_filter->getFilter()->getAttributeModel()->getAttributeId() . '_' . $filterItemVal : '0_'.$filterItemVal;
|
||||
?>
|
||||
<li class="item" data-attr-id="<?= /* @escapeNotVerified */ $block->escapeHtml($dataAttrId) ?>">
|
||||
<span class="filter-label"><?= $block->escapeHtml(__($_filter->getName())) ?></span>
|
||||
<span class="filter-value"><?= /* @escapeNotVerified */ $block->stripTags($_filter->getLabel()) ?></span>
|
||||
<?php
|
||||
$clearLinkUrl = $_filter->getClearLinkUrl();
|
||||
$currentFilterName = $block->escapeHtml(__($_filter->getName())) . " " . $block->stripTags($_filter->getLabel());
|
||||
if ($clearLinkUrl):
|
||||
?>
|
||||
<a class="action previous" href="<?= /* @escapeNotVerified */ $_filter->getRemoveUrl() ?>"
|
||||
title="<?= /* @escapeNotVerified */ __('Previous') ?>">
|
||||
<span><?= /* @escapeNotVerified */ __('Previous') ?></span>
|
||||
</a>
|
||||
<a class="action remove"
|
||||
title="<?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?>"
|
||||
href="<?= /* @escapeNotVerified */ $clearLinkUrl ?>">
|
||||
<span><?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?></span>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="action remove" href="<?= /* @escapeNotVerified */ $_filter->getRemoveUrl() ?>"
|
||||
title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Remove')) . " " . $currentFilterName ?>">
|
||||
<span><?= /* @escapeNotVerified */ __('Remove This Item') ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Category layered navigation
|
||||
*
|
||||
* @var $block WeltPixel\LayeredNavigation\Block\Navigation
|
||||
*/
|
||||
|
||||
$isAjaxMode = $block->isAjaxMode();
|
||||
$jsClass = ($isAjaxMode) ? 'WeltPixel_LayeredNavigation/js/product/list/toolbar' : false;
|
||||
?>
|
||||
<?php if ($block->canShowBlock()): ?>
|
||||
<div class="wp-filters <?php if ($isAjaxMode) echo 'wp-filters-ajax' ?>">
|
||||
<?= /* @escapeNotVerified */
|
||||
$block->getFilterButtonHtml() ?>
|
||||
</div>
|
||||
<div class="block filter" 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="<?= /* @escapeNotVerified */
|
||||
$filtered ?>">
|
||||
<strong data-role="title"><?= /* @escapeNotVerified */
|
||||
__('筛选结果') ?></strong>
|
||||
</div>
|
||||
<div class="block-content filter-content">
|
||||
<?= $block->getChildHtml('state') ?>
|
||||
|
||||
<?php if ($block->getLayer()->getState()->getFilters()): ?>
|
||||
<div class="block-actions filter-actions">
|
||||
<a href="<?= /* @escapeNotVerified */
|
||||
$block->getClearUrl() ?>" class="action clear filter-clear"><span><?= /* @escapeNotVerified */
|
||||
__('Clear All') ?></span></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $activeFilters = $block->getActiveFilters() ?>
|
||||
<?php $wrapOptions = false; ?>
|
||||
<?php foreach ($block->getFilters() as $k => $filter): ?>
|
||||
|
||||
<?php $filterAttributeId = $filter->getData('attribute_model') ? $filter->getData('attribute_model')->getAttributeId() : 0; ?>
|
||||
<?php $attributeId = (!$block->isCategoryFilter($filter)) ? $filterAttributeId : 0; ?>
|
||||
<?php if ($filter->getItemsCount()): ?>
|
||||
<?php if (!$wrapOptions): ?>
|
||||
|
||||
<div class="filter-options" id="narrow-by-list" data-role="content"
|
||||
data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": "<?php echo $activeFilters; ?>", "multipleCollapsible": true}}'>
|
||||
<?php $wrapOptions = true; ?>
|
||||
<?php endif; ?>
|
||||
<div data-role="collapsible" class="filter-options-item">
|
||||
<?php $block->getChildBlock('renderer')->setAttributeId($filter) ?>
|
||||
<div data-role="title" class="filter-options-title">
|
||||
<?= /* @escapeNotVerified */ __($filter->getName()) ?></div>
|
||||
<div id="attr_<?php echo $attributeId ?>" data-role="content"
|
||||
class="filter-options-content"><?= /* @escapeNotVerified */
|
||||
$block->getChildBlock('renderer')->render($filter) ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($wrapOptions): ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<script>
|
||||
require([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
$('#layered-filter-block').addClass('filter-no-options');
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="wp-ln-overlay"></div>
|
||||
<div class="wp-ln-slider-js" data-mage-init='<?= /* @escapeNotVerified */ $block->getWidgetOptionsJson() ?>'>
|
||||
<script>
|
||||
<?php if ($jsClass): ?>
|
||||
require.config({
|
||||
map: {
|
||||
'*': {
|
||||
"productListToolbarForm": "<?= $jsClass?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
require(['wpFilterSelect'], function(){
|
||||
wpFilterSelect.markSelected();
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
<?php $redirectUrl = $block->getRedirectUrl(); ?>
|
||||
<?php if ($redirectUrl): ?>
|
||||
<script>
|
||||
window.location.href = '<?= $redirectUrl ?>';
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user