【发布时间】:2020-10-09 01:46:36
【问题描述】:
我有一个使用 Drupal 8 的站点,我想使用 TWIG 创建一个任务计数器。
我使用带有条件的视图。无论视图是否有结果,计数器都必须递增。
这是我刚刚编写的代码:
<span class="badge badge-warning task-badge-warning">
{% if drupal_view_result('boutique_page_liste_des_taches_produit_non_publie', 'block_1') is not empty %}
1
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_role_marchand', 'block_1') is empty %}
1
{% endif %}
</span>
<span class="badge badge-danger task-badge-danger">
{% if drupal_view_result('boutique_page_liste_des_taches_aucun_produit', 'block_1') is empty %}
1
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucune_variation', 'block_1') is not empty %}
1
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_commande', 'block_1') is not empty %}
1
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_mode_de_livraison', 'block_1') is empty %}
1
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_passerelle_de_paiement', 'block_1') is empty %}
1
{% endif %}
</span>
有 2 个计数器:
- “警告”徽章
- “危险”徽章
你知道解决办法吗?
- “警告”徽章必须显示“警告”任务的总数。
- “危险”徽章必须显示“危险”任务的总数。
【问题讨论】:
-
给定代码有什么问题?你有什么努力让它发挥作用?
标签: symfony twig operators drupal-8 drupal-views