src/Eccube/Resource/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 javascript %}
  10. <script>
  11.     $(function() {
  12.     $('.ec-newsRole__news').each(function () {
  13.         var listLength = $(this).find('.ec-newsRole__newsItem').length;
  14.         if (listLength > 5) {
  15.             $(this).find('.ec-newsRole__newsItem:gt(4)').each(function () {
  16.                 $(this).hide();
  17.             });
  18.             $(this).append('<a id="news_readmore" class="ec-inlineBtn--top">{{ 'more'|trans }}</a>');
  19.                     var dispNum = 5;
  20.                     $(this).find('#news_readmore').click(function() {
  21.                         dispNum += 5;
  22.                         $(this).parent().find('.ec-newsRole__newsItem:lt(' + dispNum + ')').show();
  23.                         if (dispNum >= listLength) {
  24.                             $(this).hide();
  25.                         }
  26.                     })
  27.                 }
  28.             });
  29.             // $('.ec-newsRole__newsHeading').on('click', function() {
  30.             //     $newsItem = $(this).parent('.ec-newsRole__newsItem');
  31.             //     $newsDescription = $newsItem.children('.ec-newsRole__newsDescription');
  32.             //     if ($newsDescription.css('display') == 'none') {
  33.             //         $newsItem.addClass('is_active');
  34.             //         $newsDescription.slideDown(300);
  35.             //     } else {
  36.             //         $newsItem.removeClass('is_active');
  37.             //         $newsDescription.slideUp(300);
  38.             //     }
  39.             //     return false;
  40.             // });
  41.         });
  42.     </script>
  43. {% endblock %}
  44. <div class="ec-role">
  45.     <div class="ec-newsRole topNewsSpliter">
  46.         <div class="ec-newsRole__listTitle">
  47.             <div class="ec-newsRole__listItemHeading ec-secHeading--tandem">
  48.                 <span class="ec-secHeading__en">{{ 'NEWS'|trans }}</span>
  49.                 <span class="ec-secHeading__ja">{{ 'ニュース'|trans }}</span>
  50.             </div>
  51.             <a class="ec-recommendedBtn--more show-resultPC" href="{{ url('news_list') }}">{{ 'ニュース一覧を見る'|trans }}</a>
  52.         </div>
  53.         <div class="ec-newsRole__news">
  54.             {% for key, News in NewsList %}
  55.                 {% if key < 4 %}
  56.                     <div class="ec-newsRole__newsItem">
  57.                         <a class="ec-newsItem" href="{{ url('news_detail', {'id': News.id}) }}">
  58.                             <div class="ec-newsRole__newsHeading">
  59.                                 <div class="ec-newsRole__newsDate">
  60.                                     {{ News.publish_date|date_day }}
  61.                                 </div>
  62.                                 <div class="ec-newsRole__newsTitle">
  63.                                     {{ News.title }}
  64.                                 </div>
  65.                                 {% if key % 2 == 1 %}
  66.                                     <span class="ec-newsRole__newsBtn even">{{ 'お知らせ'|trans }}</span>
  67.                                 {% else %}
  68.                                     <span class="ec-newsRole__newsBtn odd">{{ 'お知らせ'|trans }}</span>
  69.                                 {% endif %}
  70.                             </div>
  71.                         </a>
  72.                     </div>
  73.                 {% endif %}
  74.             {% endfor %}
  75.         </div>
  76.         <div class="ec-newsRole__listTitle newsRole__listTitleBottom">
  77.             <a class="ec-recommendedBtn--more show-resultSP" href="{{ url('news_list') }}">{{ 'ニュース一覧を見る'|trans }}</a>
  78.         </div>
  79.     </div>
  80. </div>