{% block blog_content_posts %}
{% set searchResult = element.data.result %}
<div class="netzp-blog6-list" id="blog">
{% if(element.data.pluginConfig.showcategory and
element.config.category.value != null and
element.config.category.value != '00000000000000000000000000000000') %}
{% set firstPost = searchResult|first %}
{% block blog_content_category %}
<div class="card mt-4 mb-4">
<h2 class="card-header">
{{ firstPost.category.translated.title }}
</h2>
{% if(firstPost.category.translated.teaser) %}
<div class="card-body m-2">
{{ firstPost.category.translated.teaser|raw }}
</div>
{% endif %}
</div>
{% endblock %}
{% endif %}
{% if element.config.layout.value == 'slider' %}
{% sw_include "@Storefront/storefront/element/blog-index-slider.html.twig" %}
{% else %}
{% set filterUrl = null %}
{% set dataUrl = null %}
{% if page.header.navigation.active.id %}
{% set filterUrl = url('frontend.cms.navigation.filter', { navigationId: page.header.navigation.active.id }) %}
{% set dataUrl = url('frontend.cms.navigation.page', { navigationId: page.header.navigation.active.id }) %}
{% endif %}
{% set currentPage = ((searchResult.criteria.offset + 1) / searchResult.criteria.limit )|round(0, 'ceil') %}
{% set paginationConfig = { page: currentPage } %}
{% set paginationOptions = {
dataUrl: dataUrl,
filterUrl: filterUrl,
scrollTopListingWrapper: true,
snippets: {
resetAllButtonText: 'netzp.blog.filter.reset'|trans
}
} %}
<div class="cms-element-sidebar-filter">
{% if element.config.filterCategory.value or element.config.filterTags.value or element.config.filterAuthor.value %}
<button class="btn header-actions-btn filter-panel-wrapper-toggle mb-4 mb-lg-4"
type="button"
data-offcanvas-filter="true"
aria-haspopup="true"
aria-expanded="false"
aria-label="{{ "general.menuLink"|trans }}">
{% block element_product_listing_filter_button_icon %}
{% sw_icon 'sliders-horizontal' %}
{% endblock %}
{{ "listing.filterTitleText"|trans }}
</button>
<div id="filter-panel-wrapper"
class="filter-panel-wrapper"
data-offcanvas-filter-content="true">
<div class="filter-panel-offcanvas-header">
<div class="filter-panel-offcanvas-only filter-panel-offcanvas-title">{{ "listing.filterTitleText"|trans }}</div>
<div class="filter-panel-offcanvas-only filter-panel-offcanvas-close js-offcanvas-close">
{% sw_icon 'x' style { 'size': 'md' } %}
</div>
</div>
<div class="filter-panel row mt-4 mt-lg-4">
<div class="filter-panel-items-container col-12 col-lg-6">
{% set categories = searchResult.aggregations.get('categories') %}
{% set categoriesSorted = categories.entities|sort((a, b) => a.translated.title <=> b.translated.title) %}
{% if element.config.filterCategory.value and categoriesSorted %}
{% sw_include '@Storefront/storefront/element/filter/category-filter.html.twig' with {
elements: categoriesSorted,
name: 'categories',
displayName: 'netzp.blog.filter.categories'|trans
} %}
{% endif %}
{% set authors = searchResult.aggregations.get('authors') %}
{% set authorsSorted = authors.entities|sort((a, b) => a.translated.name <=> b.translated.name) %}
{% if element.config.filterAuthor.value and authorsSorted %}
{% sw_include '@Storefront/storefront/component/listing/filter/filter-multi-select.html.twig' with {
elements: authorsSorted,
name: 'authors',
displayName: 'netzp.blog.filter.authors'|trans
} %}
{% endif %}
{% set tags = searchResult.aggregations.get('tags') %}
{% set tagsSorted = tags.entities|sort((a, b) => a.name <=> b.name) %}
{% if element.config.filterTags.value and tagsSorted %}
{% sw_include '@Storefront/storefront/element/filter/tags-filter.html.twig' with {
elements: tagsSorted,
name: 'tags',
displayName: 'netzp.blog.filter.tags'|trans
} %}
{% endif %}
</div>
<div class="filter-panel-active-container col-12 col-lg-6"></div>
</div>
</div>
{% endif %}
<div class="cms-element-product-listing-wrapper"
data-listing-pagination="true"
data-listing-pagination-options='{{ paginationConfig|json_encode }}'
data-listing="true"
data-listing-options='{{ paginationOptions|json_encode }}'>
<div class="cms-element-product-listing">
<div class="row cms-listing-row js-listing-wrapper">
{% if searchResult.total > 0 %}
{% if element.config.layout.value == 'list' %}
<div class="blog-list">
{% endif %}
{% for post in searchResult.elements %}
{% if element.config.layout.value == 'cards' %}
{% sw_include "@Storefront/storefront/element/blog-index-card.html.twig" %}
{% elseif element.config.layout.value == 'list' %}
{% sw_include "@Storefront/storefront/element/blog-index-listitem.html.twig" %}
{% elseif element.config.layout.value == 'tpl' %}
{% sw_include "@Storefront/storefront/element/blog-index-template.html.twig" %}
{% endif %}
{% endfor %}
{% if element.config.layout.value == 'list' %}
</div>
{% endif %}
{% else %}
<div class="cms-listing-col col-12">
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
type: 'info', content: 'netzp.blog.msg.noposts'|trans|sw_sanitize
} %}
</div>
{% endif %}
</div>
{% if (not element.config.noPagination.value) and (searchResult.total > searchResult.limit) %}
<br>
{% sw_include '@Storefront/storefront/component/pagination.html.twig' with {
entities: searchResult,
criteria: searchResult.criteria
} %}
{% endif %}
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}