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__newsItem {
  12.         display: block;
  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="mod-btn-01 isOpen marginTop20"><span class="btnInner">もっと見る</span></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.         });
  37.     </script>
  38. {% endblock %}
  39. <div class="ec-newsRole__news top-news-list">
  40.     {% for News in NewsList %}
  41.         <article class="ec-newsRole__newsItem newsBox">               
  42.             <a href={{ url('news_detail',  {'id': News.id}) }} class="newsBoxInner">
  43.                 <div class="newsBox-header">
  44.                     <span class="newsBox-header-date">{{ News.publish_date|date('Y.m.d') }}</span>
  45.                 </div>
  46.                 <h3 class="newsBox-hl">{{ News.title }}</h3>
  47.             </a>
  48.         </article>                
  49.     {% endfor %}   
  50. </div>