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

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% set NewsList = repository('Eccube\\Entity\\News').getList() %}
  9. {% block stylesheet %}
  10.     <style>
  11.         .ec-newsRole .ec-newsRole__newsCloseBtn{
  12.             background: #C5A600;
  13.         }
  14.     </style>
  15. {% endblock %}
  16. {% block javascript %}
  17.     <script>
  18.         $(function() {
  19.             $('.ec-newsRole__news').each(function() {
  20.                 var listLength = $(this).find('.ec-newsRole__newsItem').length;
  21.                 if (listLength > 5) {
  22.                     $(this).find('.ec-newsRole__newsItem:gt(4)').each(function() {
  23.                         $(this).hide();
  24.                     });
  25.                     $(this).append('<a id="news_readmore" class="ec-inlineBtn--top">{{ 'more'|trans }}</a>');
  26.                     var dispNum = 5;
  27.                     $(this).find('#news_readmore').click(function() {
  28.                         dispNum += 5;
  29.                         $(this).parent().find('.ec-newsRole__newsItem:lt(' + dispNum + ')').show();
  30.                         if (dispNum >= listLength) {
  31.                             $(this).hide();
  32.                         }
  33.                     })
  34.                 }
  35.             });
  36.             $('.ec-newsRole__newsHeading').on('click', function() {
  37.                 $newsItem = $(this).parent('.ec-newsRole__newsItem');
  38.                 $newsDescription = $newsItem.children('.ec-newsRole__newsDescription');
  39.                 if ($newsDescription.css('display') == 'none') {
  40.                     $newsItem.addClass('is_active');
  41.                     $newsDescription.slideDown(300);
  42.                 } else {
  43.                     $newsItem.removeClass('is_active');
  44.                     $newsDescription.slideUp(300);
  45.                 }
  46.                 return false;
  47.             });
  48.         });
  49.     </script>
  50. {% endblock %}
  51.     <div class="ec-newsRole">
  52.         {# <div class="ec-secHeading">
  53.             <span class="ec-secHeading__en">{{ 'NEWS'|trans }}</span>
  54.             <span class="ec-secHeading__line"></span>
  55.             <span class="ec-secHeading__ja">{{ '新着情報'|trans }}</span>
  56.         </div> #}
  57.         <div class="ec-newsRole__news">
  58.             {% for News in NewsList %}
  59.                 <div class="ec-newsRole__newsItem">
  60.                     <div class="ec-newsRole__newsHeading">
  61.                         <div class="ec-newsRole__newsDate">
  62.                             {{ News.publish_date|date_day }}
  63.                         </div>
  64.                         <div class="ec-newsRole__newsColumn">
  65.                             <div class="ec-newsRole__newsTitle">
  66.                                 {{ News.title }}
  67.                             </div>
  68.                             {% if News.description or News.url %}
  69.                                 <div class="ec-newsRole__newsClose">
  70.                                     <a class="ec-newsRole__newsCloseBtn">
  71.                                         <i class="fas fa-angle-down"></i>
  72.                                     </a>
  73.                                 </div>
  74.                             {% endif %}
  75.                         </div>
  76.                     </div>
  77.                     <div class="ec-newsRole__newsDescription">
  78.                         {{ News.description|raw|nl2br }}
  79.                         {% if News.url %}
  80.                             <br>
  81.                             <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ '詳しくはこちら'|trans }}</a>
  82.                         {% endif %}
  83.                     </div>
  84.                 </div>
  85.             {% endfor %}
  86.         </div>
  87.     </div>