app/template/default/Block/Top/blog_list.twig line 1

Open in your IDE?
  1. {% set blogs = repository('Plugin\\CMBlogPro\\Entity\\Blog').getList() %}
  2. {% set count = 0 %}
  3. {% if blogs is defined and blogs|length > 0 %}
  4.   {% for blog in blogs %}
  5.     {% if count < maxCount %}
  6.       {# 特定カテゴリを含む ∨ 含まない処理 #}
  7.       {% set isInclude = false %}
  8.       {% set isExclude = true %}
  9.       {% if includeCategories is empty %}
  10.         {% set isInclude = true %}
  11.       {% else %}
  12.         {% for blogCategory in blog.BlogCategories %}
  13.           {% if blogCategory.CategoryId in includeCategories %}
  14.             {% set isInclude = true %}
  15.           {% endif %}
  16.         {% endfor %}
  17.       {% endif %}
  18.       {% if excludeCategories is empty %}
  19.       {% else %}
  20.         {% for blogCategory in blog.BlogCategories %}
  21.           {% if blogCategory.CategoryId in excludeCategories %}
  22.             {% set isExclude = false %}
  23.           {% endif %}
  24.         {% endfor %}
  25.       {% endif %}
  26.       {% if isInclude == true and isExclude == true %}
  27.         {% set count = count + 1 %}
  28.         <li class="home__blog-item">
  29.           <a href="{{ url('blog_detail/{id}', {'id': blog.slug ? blog.slug : blog.id}) }}">
  30.             <div class="home__blog-img-wrapper">
  31.               {% if blog.getMainListImage %}
  32.               <img src="{{ asset(blog.getMainListImage|no_image_product, 'save_image') }}" class='item_blog_image'></img>
  33.               {% else %}
  34.               <img src="{{ asset(''|no_image_product, 'save_image') }}" class='item_blog_image'></img>
  35.               {% endif %}
  36.             </div>
  37.             <div class="home__blog-text-wrapper">
  38.               <h3>{{ blog.getTitle|length > 40 ? blog.getTitle|striptags|replace({('&nbsp;'):' '})|slice(0, 40)|raw ~ '...' : blog.getTitle|raw }}</h3>
  39.               <p>{{ blog.getUpdateDate|date('Y年m月d日') }}</p>
  40.             </div>
  41.           </a>
  42.         </li>
  43.       {% endif %}
  44.     {% endif %}
  45.   {% endfor %}
  46. {% endif %}