app/template/akracing/Block/cm_blog_block_pro.twig line 1

Open in your IDE?
  1. {% set config = repository('Plugin\\CMBlogPro42\\Entity\\Config').get() %}
  2. {% set blogs = repository('Plugin\\CMBlogPro42\\Entity\\Blog').getList() %}
  3. {% set categoryLisst = repository('Plugin\\CMBlogPro42\\Entity\\Category').getFrontCategoryList() %}
  4. {% block javascript %}
  5. <script>
  6. $(function(){
  7.     $(".ak-news_header li").on("click",function(){
  8.         console.log($(this).attr("id"));
  9.         $(".ak-news_header li").removeClass("active");
  10.         $(this).addClass("active");
  11.         clikcId = $(this).attr("id");
  12.         $(".ak-news_body").removeClass("active");
  13.         $("." + clikcId ).addClass("active");
  14.     })
  15.     $("#headlint").addClass("active");
  16.     $(".headlint").addClass("active");
  17. })
  18. </script>
  19. {% endblock %}
  20. {% block stylesheet %}
  21. <style>
  22. /* style by mark */
  23. .ak-news_header{
  24.     display:flex;
  25. }
  26. #cm_blog_plugin .ak-news_header .active{
  27.     background-color:#1F1F1F
  28. }
  29. .ak-news_header h3{
  30.     font-size:14px;
  31.     margin:0;
  32.     padding:0.5em;
  33. }
  34. .ec-shelfRole{
  35.     background-color:#000;
  36. }
  37. #cm_blog_plugin .ak-news_body{
  38.     display:none;
  39.     padding:1em;
  40. }
  41. .ak-news_body li{
  42.     padding:0.5em;
  43.     font-size:14px;
  44.     display:flex;
  45.     flex-wrap: wrap;
  46.     position:relative;
  47. }
  48. .ak-news_body li span{
  49.     display:inline-block;
  50.     width:6em;
  51. }
  52. .ak-news_body li a{
  53.     width:calc(100% - 6em );
  54. }
  55. #cm_blog_plugin .ak-news_body.active{
  56.     display:block;
  57.     background-color:#1F1F1F;
  58. }
  59. /*
  60. #cm_blog_plugin{
  61.     position: absolute;
  62.     bottom:50px;
  63.     right:0;
  64.     padding:0;
  65.     max-width:700px;
  66.     z-index:500;
  67. }
  68. */
  69. #newsList{
  70.     position:relative;
  71. }
  72. #newsList::before{
  73.     content : "";
  74.     display:block;
  75.     width:100%;
  76.     padding-bottom:40%;
  77.     /* background-color:#F00;*/
  78. }
  79. #cm_blog_plugin{
  80.     position: relative;
  81.     bottom:40px;
  82.     right:0;
  83.     padding:0;
  84.     max-width:700px;
  85.     z-index:500;
  86.     margin-left:auto;
  87. }
  88. #cm_blog_plugin .ec-shelfRole,
  89. #cm_blog_plugin .ec-role,
  90. #cm_blog_plugin .ec-shelfRole{
  91.     margin:0;
  92.     padding:0;
  93. }
  94. #cm_blog_plugin ul.ak-news_header li.newsTitle{
  95.     padding:15px 110px 15px 15px;
  96. }
  97. #cm_blog_plugin ul.ak-news_header li{
  98.     padding:21px 15px 15px 15px;
  99. }
  100. #cm_blog_plugin ul.ak-news_header li.newsTitle h3{
  101.     font-size:26px;
  102.     padding:0;
  103. }
  104. #cm_blog_plugin ul.ak-news_header li.newsTitle h3::before{
  105.     content:none;
  106. }
  107. #cm_blog_plugin ul.ak-news_header li h3{
  108.     padding: 0 0 0 1em;
  109.     position: relative;
  110.     line-height:0.5;
  111. }
  112. #cm_blog_plugin ul.ak-news_header li h3::before {
  113.     position: absolute;
  114.     content: "";
  115.     color: #fff;
  116.     background-color: #fff;
  117.     width: 0.5em;
  118.     height: 2px;
  119.     top: 0.2em;
  120.     left: 0;
  121.   }
  122. .ak-news_body a{
  123.     position:relative;
  124. }
  125. .ak-news_body .new::before{
  126.     content: "NEW";
  127.     background-color:#c60a1c;
  128.     padding:0.3em;
  129.     margin:0 0.5em 0 0;
  130.     border-radius:0.3em;
  131.     font-size:10px;
  132. }
  133. @media (max-width: 1023px){
  134.     #newsList{
  135.         padding:0 20px;
  136.         margin: 50px 0 0 0;
  137.     }
  138.     #newsList::before{
  139.         content:none;
  140.     }
  141.     #cm_blog_plugin{
  142.         position: static;
  143.         bottom:0;
  144.         right:0;
  145.         padding:0;
  146.         max-width:none;
  147.         width:100%;
  148.         z-index:0;
  149.         margin-left:0;
  150.     }
  151.     #cm_blog_plugin ul.ak-news_header li.newsTitle{
  152.         padding:15px 15px 15px 15px;
  153.         flex-basis:100%;
  154.     }
  155.     .ak-news_header{
  156.         display:flex;
  157.         flex-wrap:wrap;
  158.         justify-content:space-between;
  159.     }
  160. }
  161. @media (max-width: 576px){
  162.     #cm_blog_plugin ul.ak-news_header li h3{
  163.         padding:0;
  164.     }
  165.     #cm_blog_plugin ul.ak-news_header li h3::before{
  166.         content:none;
  167.     }
  168.     #cm_blog_plugin ul.ak-news_header li#campaign{
  169.         flex-basis:49%;
  170.     }
  171.     #cm_blog_plugin ul.ak-news_header li{
  172.         padding:1em 0;
  173.         flex-basis: 17%;
  174.     }
  175.     #newsList h3{}
  176. }
  177. </style>
  178. {% endblock %}
  179. {% if blogs is defined and blogs|length > 0 %}
  180. <div id="newsList">
  181.     <div id="cm_blog_plugin" class="ec-categoryRole ">
  182.         <div class="ec-role">
  183.             <div class="ec-shelfRole">
  184.                 <ul class="ak-news_header">
  185.                     <li id="headlint" class="newsTitle"><h3 class="ec-secHeading__en">{{config.getTitleEn}}</h3></li>
  186.                     {% for i in [3,1,2,0] %}
  187.                     <li id = "{{categoryLisst[i].class}}"><h3>{{ categoryLisst[i].getName() }}</h3></li>
  188.                     {% endfor %}
  189.                 </ul>
  190.                     <ul  class="ak-news_body headlint" >
  191.                     {% set getHeadLine = repository('Plugin\\CMBlogPro42\\Entity\\Blog').getHeadLine(is_granted('ROLE_USER')) %}
  192.                     {% for blog in getHeadLine %}
  193.                             <li>
  194.                             {# blog #}
  195.                             <span class="news_release_date">{{ blog.release_date|date_day }}</span>                                
  196.                                 {% if blog.linkurl != null %}
  197.                                     {% if blog.release_date != null and blog.release_date|date('Y-m-d') > 'now'|date_modify('-1 month')|date('Y-m-d') %}
  198.                                 <a class="news_title new" href="{{ blog.linkurl }}" target="_blank">
  199.                                     {% else %}
  200.                                 <a class="news_title" href="{{ blog.linkurl }}" target="_blank">
  201.                                     {% endif %}
  202.                                     {# blog.getTitle|length > 45 ? blog.getTitle|striptags|replace({('&nbsp;'):' '})|slice(0, 45)|raw ~ '...' : blog.getTitle|raw #}
  203.                                     {{ blog.getTitle|raw }}
  204.                                 </a>
  205.                                 {% else %}
  206.                                     {% if blog.release_date != null and blog.release_date|date('Y-m-d') > 'now'|date_modify('-1 month')|date('Y-m-d') %}
  207.                                 <a class="news_title new" href="{{ url('cm_blog_page_detail', {'id': blog.id}) }}">
  208.                                     {% else %}
  209.                                 <a class="news_title" href="{{ url('cm_blog_page_detail', {'id': blog.id}) }}">
  210.                                     {% endif %}
  211.                                     {# blog.getTitle|length > 45 ? blog.getTitle|striptags|replace({('&nbsp;'):' '})|slice(0, 45)|raw ~ '...' : blog.getTitle|raw #}
  212.                                     {{ blog.getTitle|raw }}
  213.                                 </a>
  214.                                 {% endif %}    
  215.                             </li>
  216.                     {% endfor %}
  217.                     </ul>
  218.                 {% for categoryVal in categoryLisst %}
  219.                     {% set categoryValId = categoryVal.getId() %}
  220.                     <ul class="ak-news_body {{categoryVal.class}}">
  221.                     {% set news = repository('Plugin\\CMBlogPro42\\Entity\\Blog').getListTop(categoryValId,is_granted('ROLE_USER')) %}
  222.                     {% for blog in news %}
  223.                         {% for category in blog.getBlogCategories %}
  224.                             {% if category.getCategory().getId() == categoryValId %}
  225.                             {# dump(blog.release_date) #}
  226.                             <li>
  227.                             <span class="news_release_date">{{ blog.release_date|date_day }}</span>                                
  228.                                 {% if blog.linkurl != null %}
  229.                                     {% if blog.release_date != null and blog.release_date|date('Y-m-d') > 'now'|date_modify('-1 month')|date('Y-m-d') %}
  230.                                 <a class="news_title new" href="{{ blog.linkurl }}" target="_blank">
  231.                                     {% else %}
  232.                                 <a class="news_title" href="{{ blog.linkurl }}" target="_blank">
  233.                                     {% endif %}
  234.                                     {# blog.getTitle|length > 45 ? blog.getTitle|striptags|replace({('&nbsp;'):' '})|slice(0, 45)|raw ~ '...' : blog.getTitle|raw #}
  235.                                     {{ blog.getTitle|raw }}
  236.                                 </a>
  237.                                 {% else %}
  238.                                     {% if blog.release_date != null and blog.release_date|date('Y-m-d') > 'now'|date_modify('-1 month')|date('Y-m-d') %}
  239.                                 <a class="news_title new" href="{{ url('cm_blog_page_detail', {'id': blog.id}) }}">
  240.                                     {% else %}
  241.                                 <a class="news_title" href="{{ url('cm_blog_page_detail', {'id': blog.id}) }}">
  242.                                     {% endif %}
  243.                                     {# blog.getTitle|length > 45 ? blog.getTitle|striptags|replace({('&nbsp;'):' '})|slice(0, 45)|raw ~ '...' : blog.getTitle|raw #}
  244.                                     {{ blog.getTitle|raw }}
  245.                                 </a>
  246.                                 {% endif %}    
  247.                             </li>
  248.                             {% endif %}
  249.                         {% endfor %}
  250.                     
  251.                     {% endfor %}
  252.                     </ul>
  253.                 {% endfor %}
  254.             </div>
  255.         </div>
  256.     </div>
  257. </div>
  258. {% endif %}