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

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
  4. http://www.lockon.co.jp/
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  16. #}
  17. {% set NewsList = repository('Eccube\\Entity\\News').getList() %}
  18. {% block javascript %}
  19.     <script>
  20.     $(function () {
  21.         $(".newslist").each(function () {
  22.             var listLenght = $(this).find("dl").length;
  23.             if (listLenght > 5) {
  24.                 $(this).find("dl:gt(4)").each(function () {
  25.                     $(this).hide();
  26.                 });
  27.                 $(this).append('<a id="news_readmore">» もっと見る</a>');
  28.                 var dispNum = 5;
  29.                 $(this).find("#news_readmore").click(function () {
  30.                     dispNum += 5;
  31.                     $(this).parent().find("dl:lt(" + dispNum + ")").show(400);
  32.                     if (dispNum >= listLenght) {
  33.                         $(this).hide();
  34.                     }
  35.                 })
  36.             }
  37.         });
  38.     });
  39. </script>
  40. {% endblock %}
  41. <div class="news_contents">
  42.     <div id="news_area" class="nikk">
  43.         <h4 class="myn2">お知らせ<span class="sml">NEWS</span></h4>
  44.         <div class="accordion">
  45.             <div class="newslist">
  46.             {% for News in NewsList %}
  47.                 {% set newsSchools = [] %}
  48.                 {% for newsSchool in News.NewsSchool %}
  49.                     {% set newsSchools = newsSchools|merge([newsSchool.school_id]) %}
  50.                 {% endfor %}
  51.                 {% if newsSchools|length == 0 or (is_granted('ROLE_USER') and app.user.School.school_id in newsSchools) %}
  52.                 <dl>
  53.                     <dt>
  54.                         <span class="date">{{ News.publish_date|date("Y/m/d") }}</span>
  55.                         <span class="news_title">
  56.                             {{ News.title }}
  57.                         </span>
  58.                         {% if News.description or News.url %}
  59.                             <span class="angle-circle"><svg class="cb cb-angle-down"><use xlink:href="#cb-angle-down" /></svg></span>
  60.                             {% endif %}
  61.                     </dt>
  62.                     {% if News.description or News.url %}
  63.                         <dd>{{ News.description|raw|nl2br}}
  64.                             {% if News.url %}<br>
  65.                                 <a href="{{ News.url }}" {% if News.link_method == '1' %}target="_blank"{% endif %}>
  66.                                     詳しくはこちら
  67.                                 </a>{% endif %}
  68.                             </dd>
  69.                         {% endif %}
  70.                     </dl>
  71.                     {% endif %}
  72.             {% endfor %}
  73.             </div>
  74.         </div>
  75.     </div>
  76. </div>