アトリエロワ

EC-CUBE4の表示twig・サイトURLや画像パス

コンテンツ管理→ページ管理 からURLをチェック

https://●●.com/help/about
app/template/●自分のテンプレ●/Help/about.twig  の場合

<a href="{{ url('help_about') }}"> {{ 'このサイトについて'|trans }}</a>

https://●●.com/guide
app/template/●自分のテンプレ●/Help/guide.twig の場合

<a href="{{ url('help_guide') }}"> {{ '発送について'|trans }}</a>

自分で作成したページ  https://●●.com/user_data/flow
app/template/user_data/    の場合

<a href="{{ url('user_data', {'route': 'flow'}) }}">{{ '制作の流れ'|trans }}</a>

ブロックの挿入

{{ include('Block/login.twig') }}

カテゴリーページでカテゴリーごとに表示する内容を変更

{% if Category.id == 1 %}
カテゴリーID が1の時に表示

{% elseif Category.id == 2 %}
カテゴリーID が2の時に表示

{% else %}
 上記以外で表示
{% endif %}

{% set Categories = repository('Eccube\\Entity\\Category').getList() %}
{% macro tree(Category) %}
    {% from _self import tree %}
    <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
        {{ Category.name }}
    </a>
    {% if Category.children|length > 0 %}
        <ul>
            {% for ChildCategory in Category.children %}
                <li>
                    {{ tree(ChildCategory) }}
                </li>
            {% endfor %}
        </ul>
    {% endif %}
{% endmacro %}

{# @see https://github.com/bolt/bolt/pull/2388 #}
{% from _self import tree %}

        <ul>
            {% for Category in Categories %}
              {% if Category.id is not same as(1) %} ←除外カテゴリー(必要ないときは削除)
                <li>
                    {{ tree(Category) }}
                </li>
                {% endif %}←除外カテゴリーのifの終わり(必要ないときは削除)
            {% endfor %}
        </ul>

thanksページに特定のタグを貼る。google広告のコンバージョンタグなど

{% if app.request.pathinfo == '/shopping/complete' %}
        ここに貼りたいタグ
{% endif%}

HOME > EC-CUBE4 > EC-CUBE4の表示twig・サイトURLや画像パス