view.phtml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Mageplaza
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Mageplaza.com license that is
  8. * available through the world-wide-web at this URL:
  9. * https://www.mageplaza.com/LICENSE.txt
  10. *
  11. * DISCLAIMER
  12. *
  13. * Do not edit or add to this file if you wish to upgrade this extension to newer
  14. * version in the future.
  15. *
  16. * @category Mageplaza
  17. * @package Mageplaza_AjaxLayer
  18. * @copyright Copyright (c) Mageplaza (http://www.mageplaza.com/)
  19. * @license https://www.mageplaza.com/LICENSE.txt
  20. */
  21. ?>
  22. <?php if ($block->canShowBlock()): ?>
  23. <?php
  24. $filters = $block->getFilters();
  25. $layerConfig = $this->helper('Mageplaza\AjaxLayer\Helper\Data')->getLayerConfiguration($filters);
  26. $filtered = count($block->getLayer()->getState()->getFilters());
  27. ?>
  28. <div class="block filter" id="layered-filter-block"
  29. data-mage-init='{"collapsible":{"openedState": "active", "collapsible": true, "active": false, "collateral": { "openedState": "filter-active", "element": "body" } }}'>
  30. <div id="ln_overlay" class="ln_overlay">
  31. <div class="loader">
  32. <img src="<?php echo $block->getViewFileUrl('images/loader-1.gif'); ?>" alt="Loading...">
  33. </div>
  34. </div>
  35. <div class="block-title filter-title" data-count="<?php /* @escapeNotVerified */ echo $filtered; ?>">
  36. <strong data-role="title"><?php /* @escapeNotVerified */ echo __('Shop By') ?></strong>
  37. </div>
  38. <div class="block-content filter-content">
  39. <?php echo $block->getChildHtml('state') ?>
  40. <?php if ($block->getLayer()->getState()->getFilters()): ?>
  41. <div class="block-actions filter-actions">
  42. <a href="<?php /* @escapeNotVerified */ echo $block->getClearUrl() ?>"
  43. class="action clear filter-clear"><span><?php /* @escapeNotVerified */ echo __('Clear All') ?></span></a>
  44. </div>
  45. <?php endif; ?>
  46. <?php $wrapOptions = false; ?>
  47. <?php foreach ($filters as $key => $filter): ?>
  48. <?php if ($filter->getItemsCount()): ?>
  49. <?php if (!$wrapOptions): ?>
  50. <strong role="heading" aria-level="2"
  51. class="block-subtitle filter-subtitle"><?php echo __('Shopping Options') ?></strong>
  52. <div class="filter-options" id="narrow-by-list" data-role="content">
  53. <?php $wrapOptions = true;
  54. endif; ?>
  55. <div data-role="ln_collapsible" class="filter-options-item"
  56. attribute="<?php echo $filter->getRequestVar() ?>">
  57. <div data-role="ln_title" class="filter-options-title"><?php /* @escapeNotVerified */ echo __($filter->getName()) ?></div>
  58. <div data-role="ln_content" class="filter-options-content"><?php /* @escapeNotVerified */ echo $block->getChildBlock('renderer')->setFilter($filter)->render($filter); ?></div>
  59. </div>
  60. <?php endif; ?>
  61. <?php endforeach; ?>
  62. <?php if ($wrapOptions): ?>
  63. </div>
  64. <?php else: ?>
  65. <script>
  66. require([
  67. 'jquery'
  68. ], function ($) {
  69. $('#layered-filter-block').addClass('filter-no-options');
  70. });
  71. </script>
  72. <?php endif; ?>
  73. <script type="text/x-magento-init">
  74. {
  75. ".block-content.filter-content":{
  76. "mpAjax": <?php echo $layerConfig ?>
  77. }
  78. }
  79. </script>
  80. </div>
  81. </div>
  82. <?php endif; ?>