app/template/yamaria/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. {# 親カテゴリの判定|default_frameで設定 #}
  10. {% if category_base == 7 %}{# YAMASHITA #}
  11.     {% set TargetNewsCategory = 1 %}
  12.     {% set NonTargetNewsCategory = 2 %}
  13.     {% set NewsList = repository('Eccube\\Entity\\News').findby({'NewsCategory':[null,'',TargetNewsCategory],'visible':true},{'publish_date':'DESC'}) %}
  14. {#
  15.     {% set NewsList = repository('Eccube\\Entity\\News').createQueryBuilder('n').andWhere('n.NewsCategory != :news_category_id').setParameter('news_category_id', NonTargetNewsCategory).addOrderBy('n.publish_date', 'DESC').getQuery().getResult() %}
  16.     {% set NewsList = repository('Eccube\\Entity\\News').createQueryBuilder('n').andWhere('n.NewsCategory = :news_category_id').setParameter('news_category_id', TargetNewsCategory).addOrderBy('n.publish_date', 'DESC').getQuery().getResult() %}
  17. #}
  18. {% elseif category_base == 8 %}{# Maria #}
  19.     {% set TargetNewsCategory = 2 %}
  20.     {% set NonTargetNewsCategory = 1 %}
  21.     {% set NewsList = repository('Eccube\\Entity\\News').findby({'NewsCategory':[null,'',TargetNewsCategory],'visible':true},{'publish_date':'DESC'}) %}
  22. {% else %}{# 総合 #}
  23.     {% set NewsList = repository('Eccube\\Entity\\News').getList() %}
  24. {% endif %}
  25. {% block javascript %}
  26.     <script>
  27.         $(function() {
  28.             $('.ec-newsRole__news').each(function() {
  29.                 var listLength = $(this).find('.ec-newsRole__newsItem').length;
  30.                 if (listLength > 5) {
  31.                     $(this).find('.ec-newsRole__newsItem:gt(4)').each(function() {
  32.                         $(this).hide();
  33.                     });
  34.                     $(this).append('<a id="news_readmore" class="ec-inlineBtn--top">{{ 'more'|trans }}</a>');
  35.                     var dispNum = 5;
  36.                     $(this).find('#news_readmore').click(function() {
  37.                         dispNum += 5;
  38.                         $(this).parent().find('.ec-newsRole__newsItem:lt(' + dispNum + ')').show();
  39.                         if (dispNum >= listLength) {
  40.                             $(this).hide();
  41.                         }
  42.                     })
  43.                 }
  44.             });
  45.             $('.ec-newsRole__newsHeading').on('click', function() {
  46.                 $newsItem = $(this).parent('.ec-newsRole__newsItem');
  47.                 $newsDescription = $newsItem.children('.ec-newsRole__newsDescription');
  48.                 if ($newsDescription.css('display') == 'none') {
  49.                     $newsItem.addClass('is_active');
  50.                     $newsDescription.slideDown(300);
  51.                 } else {
  52.                     $newsItem.removeClass('is_active');
  53.                     $newsDescription.slideUp(300);
  54.                 }
  55.                 return false;
  56.             });
  57.         });
  58.     </script>
  59. {% endblock %}
  60. <div class="ec-role">
  61.     <div class="ec-newsRole">
  62.         <div class="ec-secHeading">
  63.             <span class="ec-secHeading__en">{{ 'NEWS'|trans }}</span>
  64.             <span class="ec-secHeading__line"></span>
  65.             <span class="ec-secHeading__ja">{{ '新着情報'|trans }}</span>
  66.         </div>
  67.         <div class="ec-newsRole__news">
  68.             {% for News in NewsList %}
  69.                 {% if News.publish_date < date() %}
  70.                 <div class="ec-newsRole__newsItem">
  71.                     <div class="ec-newsRole__newsHeading">
  72.                         <div class="ec-newsRole__newsDate">
  73.                             {{ News.publish_date|date_day }}
  74.                         </div>
  75.                         <div class="ec-newsRole__newsColumn">
  76.                             <div class="ec-newsRole__newsTitle">
  77.                                 <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ News.title }}</a>
  78.                             </div>
  79.                             {% if News.description or News.url %}
  80.                                 <div class="ec-newsRole__newsClose">
  81.                                     <a class="ec-newsRole__newsCloseBtn">
  82.                                         <i class="fas fa-angle-down"></i>
  83.                                     </a>
  84.                                 </div>
  85.                             {% endif %}
  86.                         </div>
  87.                     </div>
  88.                     <div class="ec-newsRole__newsDescription">
  89.                         {{ News.description|raw|nl2br }}
  90.                         {% if News.url %}
  91.                             <br>
  92.                             <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>{{ '詳しくはこちら'|trans }}</a>
  93.                         {% endif %}
  94.                     </div>
  95.                 </div>
  96.                 {% endif %}
  97.             {% endfor %}
  98.         </div>
  99.     </div>
  100. </div>