templates/business/front/post_detail.html.twig line 1

  1. {% extends 'foundation/front/front.html.twig' %}
    {% block body_class %}post detail{% endblock %}
    {% block javascripts %}
        {{ parent() }}
        <script type="application/ld+json">
            {
              "@context": "https://schema.org",
              "@type": "BreadcrumbList",
              "itemListElement": [
                {
                  "@type": "ListItem",
                  "position": 1,
                  "item": {
                    "@id": "{{ url('app_home') }}",
            "name": "{{ 'home'|trans }}"
          }
        },
        {
          "@type": "ListItem",
          "position": 2,
          "item": {
            "@id": "{{ url('app_posts_all') }}",
            "name": "{{ 'news'|trans }}"
          }
        },
            {% if post is defined and post.i18ns is defined and post.i18ns|length > 0 %}
                {% set localeCodeJson = post.i18ns[0].locale|split('_')|first %}
                {% set i18nJson = (app.request.locale == localeCodeJson and post.i18ns[0] is defined)
                    ? post.i18ns[0]
                    : (post.i18ns[1] is defined ? post.i18ns[1] : null) %}
    
                {% if i18nJson %}
            {
              "@type": "ListItem",
              "position": 3,
              "item": {
                "@id": "{{ app.request.uri }}",
                "name": "{{ i18nJson.name|striptags }}"
              }
            }
            {% endif %}
            {% endif %}
            ]
          }
        </script>
        <script>
            document.addEventListener("DOMContentLoaded", function () {
                let hiddenArticles = document.querySelectorAll(".article.hidden");
                let button = document.getElementById("showMore");
                button.addEventListener("click", function () {
                    let count = 0;
                    hiddenArticles.forEach(article => {
                        if (count < 3) { // Afficher 3 articles à la fois
                            article.classList.remove("hidden");
                            count++;
                        }
                    });
    
                    // Mettre à jour la liste après modification
                    hiddenArticles = document.querySelectorAll(".article.hidden");
    
                    // Cacher le bouton s'il n'y a plus d'articles cachés
                    if (hiddenArticles.length === 0) {
                        button.style.display = "none";
                    }
                });
            });
        </script>
    {% endblock %}
    {% block front %}
        <main class="m_site-main m_site-main-actualite m_position-relative">
            <div class="m_breadcumbs">
                <div class="m_container-lg">
                    <ul class="m_nav-breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
                        <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                            <a itemprop="item" href="{{ path('app_home') }}">
                                <i class="fa fa-home"></i>
                                <meta itemprop="name" content="{{ 'home'|trans }}">
                            </a>
                            <meta itemprop="position" content="1">
                        </li>
                        <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                            <a itemprop="item" href="{{ path('app_posts_all') }}">
                                {{ 'news'|trans }}
                                <meta itemprop="name" content="{{ 'news'|trans }}">
                            </a>
                            <meta itemprop="position" content="2">
                        </li>
                        {% if post is defined and post.i18ns is defined and post.i18ns|length > 0 %}
                            {% set localeCode = post.i18ns[0].locale|split('_')|first %}
                            {% set i18n = (app.request.locale == localeCode and post.i18ns[0] is defined)
                                ? post.i18ns[0]
                                : (post.i18ns[1] is defined ? post.i18ns[1] : null) %}
    
                            {% if i18n %}
                                <li class="m_m-0" itemprop="itemListElement" itemscope
                                    itemtype="https://schema.org/ListItem">
                            <span itemprop="item">
                                <span itemprop="name">{{ i18n.name|u.truncate(90, '...') }}</span>
                            </span>
                                    <meta itemprop="position" content="3">
                                </li>
                            {% endif %}
                        {% endif %}
                    </ul>
                </div>
            </div>
            {% if sectionContact is defined and sectionContact is not null
                and sectionContact.i18ns is defined and sectionContact.i18ns|length > 0 %}
    
                {% set localeCode = sectionContact.i18ns[0].locale|split('_')|first %}
                {% set i18n = (app.request.locale == localeCode and localeCode is defined)
                    ? sectionContact.i18ns[0]
                    : (sectionContact.i18ns[1] is defined ? sectionContact.i18ns[1] : sectionContact.i18ns[0]) %}
    
                {% set hasThumbnail = sectionContact.thumbnail is defined
                    and sectionContact.thumbnail is not null
                    and sectionContact.thumbnail.filename is defined %}
    
                <section class="m_section-banner m_section-page m_section-banner-details-post"
                        {% if hasThumbnail %}
                            style="background-image: url({{ path('proxy_avatar', {'path': sectionContact.thumbnail.filename}) }});"
                        {% endif %}
                >
                    <div class="m_section-banner-container m_position-relative">
                        <div class="m_container-lg m_position-relative">
                            <div class="m_section-banner-desc">
                                <span>{{ i18n.name }}</span>
                            </div>
                        </div>
                    </div>
                </section>
            {% endif %}
    
    
            <section class="m_section-page m_section-post-news">
                <div class="m_container-lg">
                    <div class="m_section-page-content">
                        <div class="m_flex">
                            <div class="m_section-page-text">
                                <div class="m_feature-image">
                                    <img alt="" title=""
                                         src="{{ post.thumbnail is defined and post.thumbnail.filename is defined
                                         ? path('proxy_avatar', {'path': post.thumbnail.filename})
                                         : asset('images/defaults/media.png') }}"/>
                                </div>
                                <div class="m_resume-text">
                                    {% set localeCode = post.i18ns[0].locale|split('_')|first %}
                                    {% set i18n = (app.request.locale  == localeCode and post.i18ns[0] is defined) ? post.i18ns[0] : (post.i18ns[1] is defined ? post.i18ns[1] : null) %}
                                    {% if i18n %}
                                        <h1 class="m_m-0">{{ i18n.name|u.truncate(90, '...') }}</h1>
                                    {% endif %}
    
                                </div>
                                <div class="m_post-date-publish">
                                    {% if app.request.locale == 'fr' %}
                                        <span>Publié le    {{ post.dateAdd|format_datetime(pattern="EEEE d MMMM yyyy", locale="fr", timezone="Europe/Paris") }} </span>
                                    {% else %}
                                        <span>Published   {{ post.dateAdd|date("l d F Y") }}</span>
                                    {% endif %}
                                </div>
                                <p>
                                    {{ i18n.description|raw }}
                                </p>
    
                            </div>
                            <div class="m_news-page-details">
                                <div class="m_listing-related-posts">
                                    <div class="m_widget-details m_widget-related-posts">
                                        <div class="m_listing-posts">
                                            {% if posts is defined and posts is not empty %}
                                                {% for elt in posts|slice(0, 3) %}
                                                    {% if elt.id != post.id and post is defined %}
                                                        {% set localeCode = elt.i18ns[0].locale|split('_')|first %}
                                                        {% set i18n = (app.request.locale == localeCode and elt.i18ns[0] is defined)
                                                            ? elt.i18ns[0]
                                                            : (elt.i18ns[1] is defined ? elt.i18ns[1] : null) %}
    
                                                        {% if i18n %}
                                                            <article class="m_item-post">
                                                                <div class="m_item-post-container m_position-relative">
                                                                    <div class="m_item-post-thumb">
                                                                        <img alt="" title=""
                                                                             src="{{ elt.thumbnail is defined and elt.thumbnail.filename is defined
                                                                             ? path('proxy_avatar', {'path': elt.thumbnail.filename})
                                                                             : asset('images/defaults/media.png') }}"/>
                                                                    </div>
                                                                    <div class="m_item-post-content">
                                                                        <h3>{{ i18n.name|u.truncate(90, '...') }}</h3>
                                                                        <div class="m_item-post-excerpt">
                                                                            <p>
                                                                                {{ i18n.description|u.truncate(120, '...')|raw }}
                                                                            </p>
                                                                        </div>
                                                                        <a href="{{ path('app_posts_detail', {'id': elt.id,'slug':i18n.slug}) }}"
                                                                           class="m_link-blue-underline">Lire plus</a>
                                                                    </div>
                                                                    <a class="m_link-overlay"
                                                                       href="{{ path('app_posts_detail', {'id': elt.id,'slug':i18n.slug}) }}"
                                                                       title=""></a>
                                                                </div>
                                                            </article>
                                                        {% endif %}
                                                    {% endif %}
                                                {% endfor %}
                                            {% endif %}
    
                                        </div>
                                    </div>
                                    <div class="m_widget-details m_widget-recent-posts">
                                        <h2 class="">
                                            {{ 'recent.posts'|trans }}
                                        </h2>
                                        <ul>
                                            {% if posts is defined and posts is not empty %}
                                                {% for elt in posts|slice(0, 4) %}
                                                    {% if elt.id != post.id %}
                                                        {% set localeCode = elt.i18ns[0].locale|split('_')|first %}
                                                        {% set i18n = (app.request.locale == localeCode and elt.i18ns[0] is defined)
                                                            ? elt.i18ns[0]
                                                            : (elt.i18ns[1] is defined ? elt.i18ns[1] : null) %}
    
                                                        {% if i18n %}
                                                            <li>
    <span class="post-time">
        {% if diff.days == 0 %}
            {% if diff.h < 1 %}
                {{ 'Il y a'|trans }} {{ diff.i }} {{ 'minutes'|trans }}
            {% else %}
                {{ 'Il y a'|trans }} {{ diff.h }} {{ 'heures'|trans }}
            {% endif %}
        {% elseif diff.days < 7 %}
            {{ 'Il y a'|trans }} {{ diff.days }} {{ 'jours'|trans }}
        {% else %}
            {{ elt.publishedDate|format_date(locale= app.request.locale, pattern='d MMMM y') }}
        {% endif %}
        .
    </span>
    
                                                                <a href="{{ path('app_posts_detail', {'id': elt.id,'slug':i18n.slug}) }}"> {{ i18n.name|u.truncate(90, '...') }} </a>
                                                            </li>
                                                        {% endif %}
                                                    {% endif %}
                                                {% endfor %}
                                            {% endif %}
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
    
            <section class="m_section-page m_section-page-actualites">
                <div class="m_container-lg">
                    <div class="m_section-page-content">
                        <div class="m_section-page-text">
                            <div class="m_section-page-title m_text-center">
                                <h2 class="m_underline-title m_m-0">
                                    {{ 'other.news'|trans }}
                                </h2>
                            </div>
                        </div>
                    </div>
                    <div class="m_recent-news">
                        <div class="m_flex m_listing-news">
                            {% if posts is defined and posts is not empty %}
                                {% for elt in posts %}
                                    {% if elt.id != post.id and post is defined %}
                                    <article class="article {% if loop.index > 6 %}hidden{% endif %} m_item-news  m_item-post ">
                                        <div class="m_item-news-container m_position-relative">
                                            <div class="m_item-news-thumb m_item-post-thumb">
                                                <img alt="" title=""
                                                     src="{{ elt.thumbnail is defined and elt.thumbnail.filename is defined
                                                     ? path('proxy_avatar', {'path': elt.thumbnail.filename})
                                                     : asset('images/defaults/media.png') }}"/>
                                            </div>
                                            <div class="m_item-news-content m_item-post-content">
                                                {% set localeCode = elt.i18ns[0].locale|split('_')|first %}
                                                {% set i18n = (app.request.locale == localeCode and elt.i18ns[0] is defined) ? elt.i18ns[0] : (elt.i18ns[1] is defined ? elt.i18ns[1] : null) %}
                                                {% if i18n %}
    
                                                    {# Affichage de la date de publication #}
                                                    {% if elt.publishedDate is defined %}
                                                        <time datetime="{{ elt.publishedDate|date('Y-m-d') }}" class="m_post-date">
                                                            {{ elt.publishedDate|format_date(locale= app.request.locale, pattern='d MMMM y') }}
    
                                                        </time>
                                                    {% endif %}
                                                    {% if elt.category is defined and elt.category.i18ns is defined %}
                                                        {% set categoryI18n =(app.request.locale == localeCode and  elt.category.i18ns[0] is defined) ?  elt.category.i18ns[0] : ( elt.category.i18ns[1] is defined ?  elt.category.i18ns[1] : null) %}
                                                        {% if categoryI18n is defined %}
                                                            <div class="m_badge-category">
                                                                {{ categoryI18n.name }}
                                                            </div>
                                                        {% endif %}
                                                    {% endif %}
                                                    <h3>{{ i18n.name|u.truncate(90, '...') }}</h3>
                                                    <div class="m_item-news-excerpt m_item-post-excerpt">
                                                        <p>{{ i18n.description|u.truncate(120, '...')|raw }}</p>
                                                    </div>
                                                {% endif %}
                                                <a href="{{ path('app_posts_detail',{'id':elt.id,'slug':i18n.slug}) }}"
                                                   class="m_underline-link-blue"
                                                   title={{ 'see.more'|trans }}>{{ 'see.more'|trans }}</a>
                                            </div>
                                            <a href="{{ path('app_posts_detail',{'id':elt.id,'slug':i18n.slug}) }}" class="m_link-overlay"
                                               title={{ 'see.more'|trans }}></a>
                                        </div>
                                    </article>
                                {% endif %}
                                {% endfor %}
                            {% endif %}
    
    
                        </div>
    
                        {% if posts is defined and posts|length > 6 %}
                            <div class="m_flex m_btn-flex">
                                <button id="showMore" class="m_btn-load-more">{{ 'view.more'|trans }}<i
                                            class="fa fa-angle-down"></i></button>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </section>
    
        </main>
    
    {% endblock %}