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

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