app/template/default/Block/news.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE, Overwrite by INSPIRATION
  3. #}
  4. {% set NewsList = repository('Eccube\\Entity\\News').getList() %}
  5. {% block javascript %}
  6.     <script>
  7.         $(function() {
  8.             $('.ec-newsRole__news').each(function() {
  9.                 var listLength = $(this).find('.ec-newsRole__newsItem').length;
  10.                 if (listLength > 5) {
  11.                     $(this).find('.ec-newsRole__newsItem:gt(4)').each(function() {
  12.                         $(this).hide();
  13.                     });
  14.                     $(this).append('<a id="news_readmore" class="ec-inlineBtn--top">{{ 'more'|trans }}</a>');
  15.                     var dispNum = 5;
  16.                     $(this).find('#news_readmore').click(function() {
  17.                         dispNum += 5;
  18.                         $(this).parent().find('.ec-newsRole__newsItem:lt(' + dispNum + ')').show();
  19.                         if (dispNum >= listLength) {
  20.                             $(this).hide();
  21.                         }
  22.                     })
  23.                 }
  24.             });
  25.             $('.ec-newsRole__newsHeading').on('click', function() {
  26.                 $newsItem = $(this).parent('.ec-newsRole__newsItem');
  27.                 $newsDescription = $newsItem.children('.ec-newsRole__newsDescription');
  28.                 if ($newsDescription.css('display') == 'none') {
  29.                     $newsItem.addClass('is_active');
  30.                     $newsDescription.slideDown(300);
  31.                 } else {
  32.                     $newsItem.removeClass('is_active');
  33.                     $newsDescription.slideUp(300);
  34.                 }
  35.                 return false;
  36.             });
  37.         });
  38.     </script>
  39. {% endblock %}
  40.         <div class="text-center my-5">
  41.             <h1 class="fw-bold _fs-5">{{ 'ゴルフプリントからのお知らせ'|trans }}</h1>
  42.         </div>
  43.         <div class="ec-newsRole__news border border-3 border-ec-gray p-3 p-sm-5">
  44.             {# 2025.03.24 内容も多くないので、表示件数を3件とした #}
  45.             {% for News in NewsList|slice(0,3) %}
  46.             <div class="ec-newsRole__newsItem">
  47.                 <dl class="ec-newsRole__newsHeading info-container" style="cursor: pointer;">
  48.                     <dd class="ec-newsRole__newsDate date me-3">{{ News.publish_date|date('Y.m.d') }}</dd>
  49.                     <dt class="ec-newsRole__newsColumn info ms-3"><span class="ec-newsRole__newsTitle">{{ News.title }}</span></dt>
  50.                 </dl>
  51.                 <div class="ec-newsRole__newsDescription" style="margin-bottom: 1rem; display: none;">
  52.                     {{ News.description|raw|nl2br }}
  53.                     {% if News.url %}
  54.                         <br>
  55.                         <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ '詳しくはこちら'|trans }}</a>
  56.                     {% endif %}
  57.                 </div>
  58.             </div>
  59.             {% endfor %}
  60.         </div>