app/template/HF4002/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" style="color:white !important;margin-top: 1em;">{{ '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. <style>
  45.     .ec-newsRole{
  46.         padding-top: 15px!important;
  47.     }
  48.     .ec-secHeading__ja{
  49.         margin-bottom: 0px!important;
  50.     }
  51.     @media only screen and (min-width: 768px){
  52.         .ec-secHeading{
  53.             margin-bottom: 15px!important;
  54.         }
  55.         .ec-newsRole__newsItem{
  56.             padding: 12px 0px !important;
  57.         }
  58.         .ec-newsRole__newsDescription{
  59.             margin-top: 10px!important;
  60.         }
  61.     }
  62. </style>
  63. <div class="ec-role">
  64.     <div class="ec-newsRole">
  65.         <div class="ec-secHeading">
  66.             <span class="ec-secHeading__en">{{ 'NEWS'|trans }}</span>
  67.             <span class="ec-secHeading__ja">{{ '新着情報'|trans }}</span>
  68.         </div>
  69.         <div class="ec-newsRole__news">
  70.             {% for News in NewsList %}
  71.                 <div class="ec-newsRole__newsItem">
  72.                     <div class="ec-newsRole__newsHeading">
  73.                         <div class="ec-newsRole__newsDate">
  74.                             {{ News.publish_date|date_day }}
  75.                         </div>
  76.                         <div class="ec-newsRole__newsColumn">
  77.                             <div class="ec-newsRole__newsTitle">
  78.                                 {{ News.title }}
  79.                             </div>
  80.                             {% if News.description or News.url %}
  81.                                 <div class="ec-newsRole__newsClose">
  82.                                     <a class="ec-newsRole__newsCloseBtn">
  83.                                         <i class="fas fa-angle-down"></i>
  84.                                     </a>
  85.                                 </div>
  86.                             {% endif %}
  87.                         </div>
  88.                     </div>
  89.                     <div class="ec-newsRole__newsDescription">
  90.                         {{ News.description|raw|nl2br }}
  91.                         {% if News.url %}
  92.                             {% if News.description != '' %}<br>{% endif %}
  93.                             <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ '詳しくはこちら'|trans }}</a>
  94.                         {% endif %}
  95.                     </div>
  96.                 </div>
  97.             {% endfor %}
  98.         </div>
  99.     </div>
  100. </div>