[英]How to display blocks according to the conditions of the current user?
我有一个带有 Drupal Commerce 2.14 的 Drupal 8.7 站点
我还安装了 TWIG Tweak 模块。
我想在我的 TWIG 文件中根据当前用户的某些条件显示文本。
谢谢你的帮助。
我为我想要的每个条件写了一条评论。
这是我的页面的代码:
Les étapes pour vendre sur laplateforme
<div class="mb-3">
{% if logged_in %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Incrivez-vous sur la plateforme
</div>
{# IF THE CURRENT USER TO CREATE A "PRO" TYPE STORE #}
<div class="mb-3">
{% if ??? %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Créer votre boutique
</div>
<div class="mb-3">
{% if logged_in %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Créer vos conditions générales de vente
</div>
<div class="mb-3">
{% if 'marchand_pro' in user.getroles %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Attendre que l'administrateur de la plateforme valide votre boutique
</div>
{# IF THE CURRENT USER CREATING A PRODUCT IN A "PRO" TYPE STORE #}
<div class="mb-3">
{% if ??? %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Créer vos produits ou services
</div>
{# IF THE CURRENT USER CREATES A SHIPPING METHOD IN A "PRO" TYPE STORE #}
<div class="mb-3">
{% if ??? %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Créer les modes de livraison
</div>
{# IF THE CURRENT USER CREATES A PAYMENT GATEWAY IN A "PRO" TYPE STORE #}
<div class="mb-3">
{% if ??? %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Associer la passerelle de paiement
</div>
<div class="mb-3">
{% if 'marchand_premium' in user.getroles %}
<i class="fas fa-clipboard-check fa-2x"></i>
{% else %}
<i class="fas fa-clipboard fa-2x"></i>
{% endif %}
Activer le compte premium
</div>
尝试在自定义模块中实现块插件和主题功能。 在块插件的“构建”方法中,添加所有逻辑并将结果作为变量传递给块模板。
https://www.drupal.org/docs/8/creating-custom-modules/creating-custom-blocks/create-a-custom-block
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.