{% sw_extends '@MoorlFoundation/plugin/moorl-foundation/listing.html.twig' %} {# Case 1: From widget or search page - $searchResult is set #} {% if searchResult %} {% set isListing = true %} {% set params = {search: page.searchTerm, tab: activeTab} %} {% elseif element.data.listing %} {% set searchResult = element.data.listing %} {% set config = element.fieldConfig.elements %} {% if config.listingSource.value == 'auto' %} {# Case 2: From CMS (auto) - $element is set #} {% set isListing = true %} {% set params = {slots: element.id, 'no-aggregations': 1} %} {% set filterUrl = url('frontend.cms.navigation.filter', { navigationId: searchResult.currentFilters.navigationId }) %} {% set dataUrl = url('frontend.cms.navigation.page', { navigationId: searchResult.currentFilters.navigationId }) %} {% else %} {# Case 3: From CMS (others) #} {% set isListing = false %} {% endif %} {% elseif collection and config %} {# Case 4: Static list + plugin config #} {% set isListing = false %} {% set searchResult = collection %} {% endif %} {% if isListing %} {# Case 1: From widget or search page - $searchResult is set #} {# Case 2: From CMS (auto) - $element is set #} {% set currentPage = ((searchResult.criteria.offset + 1) / searchResult.criteria.limit )|round(0, 'ceil') %} {% set paginationConfig = {page: currentPage} %} {% if disableEmptyFilter is not defined %} {% set disableEmptyFilter = config('core.listing.disableEmptyFilterOptions') %} {% endif %} {% set listingPagination = { sidebar: (sectionType == 'sidebar'), params: params, dataUrl: dataUrl, filterUrl: filterUrl, disableEmptyFilter: disableEmptyFilter, snippets: { resetAllButtonText: 'listing.filterPanelResetAll'|trans|sw_sanitize } } %} {% endif %} {% block moorl_foundation_listing %} {% if isListing %}
{% if searchResult.total > 0 %} {# Avoid not necessary pagination or sorting elements #} {% set totalPages = (searchResult.total / searchResult.criteria.limit)|round(0, 'ceil') %} {% if totalPages > 1 or searchResult.availableSortings.count() > 1 %}
{% sw_include '@Storefront/storefront/component/pagination.html.twig' with { entities: searchResult, criteria: searchResult.criteria } %}
{% sw_include '@Storefront/storefront/component/sorting.html.twig' with { current: searchResult.sorting, sortings: searchResult.availableSortings } %}
{% endif %} {% endif %} {% if searchResult.total > 0 %} {{ parent() }} {% if totalPages > 1 %} {% sw_include '@Storefront/storefront/component/pagination.html.twig' with { entities: searchResult, criteria: searchResult.criteria } %} {% endif %} {% else %} {% block moorl_foundation_listing_empty %} {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with { type: 'info', content: 'listing.emptyResultMessage'|trans|sw_sanitize } %} {% endblock %} {% endif %}
{% else %} {% if searchResult.count > 0 %} {{ parent() }} {% endif %} {% endif %} {% endblock %}