templates/front/blog/blog.twig line 1

Open in your IDE?
  1. {% extends "front/layouts/default.twig" %}
  2. {% block content %}
  3.  <div class="bg-nav space-under-nav">
  4.         <div class="container">
  5.             <div class="row justify-content-center">
  6.                 <div class="col-12">
  7.                     <div class="row align-items-center filter__list uppercase mt-lg-3">
  8.                         <div class="col-auto">
  9.                             <a href="{{ path('front-page', {url: get_page_url(app.request.locale, constant('App\\Config\\Pages::HOMEPAGE'))}) }}" class="btn filter__button back-btn text-nowrap"><span
  10.                                     class="fz-20 text-secondary">
  11.                                 < </span>{{ 'USER_ZONE.BLOG.BUTTON_FIRST'|trans() }}</a>
  12.                         </div>
  13.                     </div>
  14.                 </div>
  15.             </div>
  16.         </div>
  17.     </div>
  18.     <div class="container">
  19.         <div class="row justify-content-center">
  20.             <div class="col-12 mt-5">
  21.                 <div class="row">
  22.                     <div class="content-wrapper col-lg-8">
  23.                         <div class="row header">
  24.                             <h1>{{ 'USER_ZONE.BLOG.TEXT_FIRST'|trans() }}</h1>
  25.                         </div>
  26.                     </div>
  27.                 </div>
  28.                 <div class="row page-nav mt-4">
  29.                     <div class="col-12">
  30.                         <div class="row">
  31.                             <div class="col-12 col-lg-12">
  32.                                 <div class=" py-2 border-2 border-top border-bottom border-nonary">
  33.                                     <div class="row justify-content-start fz-14 bold text-octonary align-items-center filter-checkbox">
  34.                                         <div class="mx-2 fmx-lg-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  35.                                             <a href="#" class="text-octonary filter_blog" data-filter-key="category" data-filter="all">{{ 'USER_ZONE.BLOG.LIST_ITEM_1'|trans() }}</a>
  36.                                         </div>
  37.                                         <div class="mx-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  38.                                             <div class="row custom-select py-lg-0">
  39.                                                 <select name="blog-select" id="blog-select" class="filter-industry">
  40.                                                         <option value="" selected>{{ 'USER_ZONE.BLOG.ALL_INDUSTRY'|trans }}</option>
  41.                                                     {% for industry in industrys %}
  42.                                                         <option value="{{ industry.name|default('') != '' ? industry.name|default('') : industry.translation['en']['nameCategory']|default('') }}" {% if app.request.attributes.get('originalRequest').query.get('industry') == (industry.name|default('') != '' ? industry.name|default('') : industry.translation['en']['nameCategory']|default('')) %}selected{% endif %}>
  43.                                                         {% if app.request.locale == "pl" %}
  44.                                                             {{ industry.name|default('') != '' ? industry.name|default('') : industry.translation['en']['nameCategory']|default('') }}
  45.                                                         {% else %}
  46.                                                             {{ industry.translation['en']['nameCategory']|default('') != '' ? industry.translation['en']['nameCategory']|default('') : industry.name|default('') }}
  47.                                                         {% endif %}
  48.                                                         </option>
  49.                                                     {% endfor %}
  50.                                                 </select>
  51.                                                 <label for="blog-select" class="custom-arrow custom-arrow-black"></label>
  52.                                             </div>
  53.                                         </div>
  54.                                         <div class="mx-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  55.                                             <a href="#" class="text-octonary filter_blog" data-filter-key="category" data-filter="general">{{ 'USER_ZONE.BLOG.LIST_ITEM_5'|trans() }}</a>
  56.                                         </div>
  57.                                         <div class="mx-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  58.                                             <a href="#" class="text-octonary filter_blog" data-filter-key="category" data-filter="advice">{{ 'USER_ZONE.BLOG.LIST_ITEM_2'|trans() }}</a>
  59.                                         </div>
  60.                                         <div class="mx-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  61.                                             <a href="#" class="text-octonary filter_blog" data-filter-key="category" data-filer-key="category"data-filter="job">{{ 'USER_ZONE.BLOG.LIST_ITEM_3'|trans() }}</a>
  62.                                         </div>
  63.                                         <div class="mx-2 mt-3 mt-lg-0 col-5 col-lg-auto">
  64.                                             <a href="#" class="text-octonary filter_blog" data-filter-key="category" data-filter="benefits">{{ 'USER_ZONE.BLOG.LIST_ITEM_4'|trans() }}</a>
  65.                                         </div>
  66.                                     </div>
  67.                                 </div>
  68.                             </div>
  69.                         </div>
  70.                     </div>
  71.                 </div>
  72.                 <div class="row py-5 border-bottom border-nonary">
  73.                 {% for blog in blogs %}
  74.                     <div class="col-lg-4 col-12 col-sm-6">
  75.                         <div class="blog-card">
  76.                             <div class="blog-card-content">
  77.                                 <div class="row">
  78.                                     <div class="col-12">
  79.                                         {% for photo in blog.photo %}
  80.                                             <a href="{{ path('front-page', {url: get_page_only_url(app.request.locale, blog.id )}) }}">
  81.                                                 <img src="{{asset('blog/' ~ photo.fileName ~ '.' ~ photo.extension)|imagine_filter('blog_img') }}" alt="">
  82.                                             </a>
  83.                                         {% endfor %}
  84.                                     </div>
  85.                                     <div class="col-12 mt-3">
  86.                                         <span class="blog-card-date">{{blog.createdAt|date('d.m.Y')}} | {{ blog.fullName }}</span>
  87.                                     </div>
  88.                                     <div class="col-12 mt-2">
  89.                                         <h2 class="blog-card-h2 mb-0">
  90.                                             <a href="{{ path('front-page', {url: get_page_only_url(app.request.locale, blog.id )}) }}">
  91.                                                 <p class="m-0 p-0" style="
  92.                                                 text-overflow: ellipsis;
  93.                                                 overflow: hidden;
  94.                                                 white-space: nowrap;">
  95.                                                 {% if app.request.locale == "pl" %}
  96.                                                     {{blog.title}}
  97.                                                 {% endif %}
  98.                                                 {% if app.request.locale == "en" %}
  99.                                                     {{blog.translation['title'] ?? ''}}
  100.                                                 {% endif %}
  101.                                                 </p>
  102.                                             </a>
  103.                                         </h2>
  104.                                     </div>
  105.                                     <div class="col-12">
  106.                                         <p style="
  107.                                         text-overflow: ellipsis;
  108.                                         overflow: hidden;
  109.                                         white-space: nowrap;">
  110.                                         {% if app.request.locale == "pl" %}
  111.                                             {{ blog.passion }}
  112.                                         {% endif %}
  113.                                         {% if app.request.locale == "en" %}
  114.                                             {{ blog.translation['passion'] ?? '' }}
  115.                                         {% endif %}
  116.                                         </p>
  117.                                     </div>
  118.                                 </div>
  119.                             </div>
  120.                             <div class="col-12 mt-4 text-center">
  121.                                 <a href="{{ path('front-page', {url: get_page_only_url(app.request.locale, blog.id)}) }}" class="btn btn-outline-info btn-md">{{ 'USER_ZONE.BLOG.BUTTON_READ'|trans() }}</a>
  122.                             </div>
  123.                         </div>
  124.                     </div>
  125.                  {% endfor  %}
  126.                 </div>
  127.                 <div class="col-auto mb-5 text-center pagination-wrapper">
  128.                     <a href="#" class="custom-arrow pagination pagination-back button-pagination" data-filter-key="page" data-filter-value="{{ (thisPage) - 1 > 1 ? (thisPage) - 1 : 1 }}"></a>
  129.                     <div>
  130.                         <label class="pagination-label" for="quantity">{{ thisPage }} {{ 'USER_ZONE.PAGINATION.OUT_OF'|trans }} {{ maxPages }}</label>
  131.                     </div>
  132.                     <a href="#" class="custom-arrow pagination pagination-next button-pagination" data-filter-key="page" data-filter-value="{{ (thisPage) + 1 <= maxPages ? (thisPage) + 1 : thisPage }}"></a>
  133.                 </div>
  134.             </div>
  135.         </div>
  136.     </div>
  137.     </div>
  138. {% endblock %}
  139. {% block script %}
  140. <script>
  141.     let filters = [];
  142.     let filtersString = '';
  143.     let page = '';
  144.     let searchParams = new URLSearchParams(window.location.search);
  145.     let industry = searchParams.get('industry');
  146.     let category = searchParams.get('category');
  147.     $(document).on('click','.filter_blog',function(){
  148.         $('.checked-filter').removeClass('checked-filter');
  149.         $(this).addClass('checked-filter');
  150.      
  151.         createFiltersString();
  152.         let url = buildUrl();
  153.       
  154.         window.history.pushState({path: url}, '', url);
  155.         $.get(url, function (data) {
  156.            location.reload();
  157.         })
  158.     });
  159.     function createFiltersString() {
  160.         filtersString = '';
  161.         page = '';
  162.         $('.filter-checkbox .checked-filter').each(function() {
  163.             if($('.filter-industry').val() != ''){
  164.                 if (filtersString === '') {
  165.                     filtersString += '?';
  166.                     filtersString += 'industry' + '=' + $('.filter-industry').val();
  167.                 } else {
  168.                     filtersString += '&';
  169.                     filtersString += 'industry' + '=' + $('.filter-industry').val();
  170.                 }
  171.             }
  172.                 if (filtersString === '') {
  173.                     filtersString += '?';
  174.                     filtersString += $(this).data('filter-key') + '=' + $(this).data('filter');
  175.                 } else {
  176.                     filtersString += '&';
  177.                     filtersString += $(this).data('filter-key') + '=' + $(this).data('filter');
  178.                 }
  179.                 if($(this).data('filter') == "all"){
  180.                     filtersString = '';
  181.                 }else{
  182.                     page += '&page=1'; 
  183.                 }
  184.                
  185.             // }
  186.         });
  187.     }
  188.     function createPage(button) {
  189.         filtersString = '';
  190.         page = '';
  191.         if(industry){
  192.             filtersString = '?industry='+industry;
  193.             if(category)
  194.             {
  195.                filtersString += '&category='+category;
  196.             }
  197.             page += '&';
  198.             page += $(button).data('filter-key') + '=' + $(button).data('filter-value');
  199.         }else{
  200.             page += '?';
  201.             page += $(button).data('filter-key') + '=' + $(button).data('filter-value');
  202.         }
  203.     }
  204.     createFiltersString();
  205.     $(document).on('change', '.filter-industry', function (e) {
  206.         let url = buildUrl();
  207.         window.history.pushState({path: url}, '', url);
  208.         if (filtersString === '') {
  209.             url += '?industry=' + $('.filter-industry').val() + '&' + 'page=1' ;
  210.         } else {
  211.             url += '&industry=' + $('.filter-industry').val() + '&' + 'page=1' ;
  212.         }
  213.         if($('.filter-industry').val() == ""){
  214.             url = '';
  215.         }
  216.         window.history.pushState({path: url}, '', url);
  217.         $.get(url, function (data) {
  218.            location.reload();
  219.         })
  220.     });
  221.     $(document).on('click', '.button-pagination', function (e) {
  222.         createPage($(this));
  223.         let url = buildUrl();
  224.         window.history.pushState({path: url}, '', url);
  225.         location.reload();
  226.         return false;
  227.     });
  228.     function buildUrl() {
  229.         let newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + filtersString + page;
  230.         return newUrl;
  231.     }
  232. </script>
  233. {% endblock %}