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

Open in your IDE?
  1. {% set NewsList = repository('Eccube\\Entity\\News').getList() %}
  2. {% block javascript %}
  3.     <script>
  4.         $(function() {
  5.             $('.ec-newsRole__news').each(function() {
  6.                 var listLength = $(this).find('.ec-newsRole__newsItem').length;
  7.                 if (listLength > 5) {
  8.                     $(this).find('.ec-newsRole__newsItem:gt(4)').each(function() {
  9.                         $(this).hide();
  10.                     });
  11.                     $(this).append('<div style="text-align: center;"><a id="news_readmore" class="news_readmore"><img src="{{ asset('assets/img/top_page/link_show_more_news.png', 'user_data') }}"></a></div>');
  12.                     var dispNum = 5;
  13.                     $(this).find('#news_readmore').click(function() {
  14.                         dispNum += 5;
  15.                         $(this).parent().parent().find('.ec-newsRole__newsItem:lt(' + dispNum + ')').show();
  16.                         if (dispNum >= listLength) {
  17.                             $(this).hide();
  18.                         }
  19.                     })
  20.                 }
  21.             });
  22.             $('.ec-newsRole__newsHeading').on('click', function() {
  23.                 $newsItem = $(this).parent('.ec-newsRole__newsItem');
  24.                 $newsDescription = $newsItem.children('.ec-newsRole__newsDescription');
  25.                 if ($newsDescription.css('display') == 'none') {
  26.                     $newsItem.addClass('is_active');
  27.                     $newsDescription.slideDown(300);
  28.                 } else {
  29.                     $newsItem.removeClass('is_active');
  30.                     $newsDescription.slideUp(300);
  31.                 }
  32.                 return false;
  33.             });
  34.         });
  35.     </script>
  36. {% endblock %}
  37. {% block stylesheet %}
  38.     <style>
  39.     .ec-newsRole .ec-newsRole__newsDate {
  40.         color: #525263;
  41.         font-size: 12px;
  42.         font-style: normal;
  43.         font-weight: 600;
  44.         line-height: 16px;
  45.     }
  46.     .ec-newsRole .ec-newsRole__newsTitle {
  47.         color: #000;
  48.         font-size: 14px;
  49.         font-style: normal;
  50.         font-weight: 700;
  51.         line-height: 20px;
  52.     }
  53.     .ec-newsRole .ec-newsRole__newsDescription {
  54.         color: #000;
  55.         font-size: 14px;
  56.         font-style: normal;
  57.         font-weight: 600;
  58.         line-height: 20px;
  59.     }
  60.     .fas {
  61.         font-size: 23px;
  62.     }
  63.     .ec-newsRole__newsDescription .detail_link {
  64.         display: block; margin-top: 8px;
  65.         color: #337AB7;
  66.         font-size: 14px;
  67.         font-style: normal;
  68.         font-weight: 600;
  69.         line-height: 20px;
  70.     }
  71.     .ec-newsRole .ec-newsRole__newsCloseBtn {
  72.         display: block;
  73.         margin-left: auto;
  74.         border-radius: 100%;
  75.         width: 20px;
  76.         height: 24px;
  77.         color: black;
  78.         text-align: center;
  79.         background: none;
  80.         cursor: pointer;
  81.         position: absolute;
  82.         right: 5px;
  83.     }
  84.     .news_readmore img {
  85.         max-width: 88px;
  86.         margin-top: 26px;
  87.         margin-bottom: 10px;
  88.     }
  89.     </style>
  90. {% endblock %}
  91. <div class="ec-role" style="padding-left: 16px; padding-right: 16px; margin-bottom: 104px;">
  92.     <div class="ec-newsRole" style="padding: 0px;">
  93.         
  94.         <div class="block_content" style="margin-bottom: 32px;">
  95.             <img src="{{ asset('assets/img/top_page/text_4.png', 'user_data') }}" alt="NEWS|お知らせ" style="width: 100%; width: 450px;">    
  96.         </div>
  97.         <div class="ec-newsRole__news" style="border: none; padding: 0px;">
  98.             {% for News in NewsList %}
  99.                 <div class="ec-newsRole__newsItem">
  100.                     <div class="ec-newsRole__newsHeading">
  101.                         <div class="ec-newsRole__newsDate">
  102.                             {{ News.publish_date|date_day }}
  103.                         </div>
  104.                         <div class="ec-newsRole__newsColumn">
  105.                             <div class="ec-newsRole__newsTitle">
  106.                                 {{ News.title }}
  107.                             </div>
  108.                             {% if News.description or News.url %}
  109.                                 <div class="ec-newsRole__newsClose">
  110.                                     <a class="ec-newsRole__newsCloseBtn">
  111.                                         <i class="fas fa-angle-down"></i>
  112.                                     </a>
  113.                                 </div>
  114.                             {% endif %}
  115.                         </div>
  116.                     </div>
  117.                     <div class="ec-newsRole__newsDescription">
  118.                         {{ News.description|raw|nl2br }}
  119.                         {% if News.url %}
  120.                             <br>
  121.                             <a class="detail_link" href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ '詳しくはこちら'|trans }}</a>
  122.                         {% endif %}
  123.                     </div>
  124.                 </div>
  125.             {% endfor %}
  126.         </div>
  127.     </div>
  128. </div>