Javascript 如何计算页面的类数以在菜单中显示它?
我有一个Drupal8.8.4站点,具有Bootstrap3.4.1主题 我已经创建了一个商店视图页面来显示商家要执行的任务 在此页面上,每个任务对应一个视图块:Javascript 如何计算页面的类数以在菜单中显示它?,javascript,php,css,drupal,drupal-8,Javascript,Php,Css,Drupal,Drupal 8,我有一个Drupal8.8.4站点,具有Bootstrap3.4.1主题 我已经创建了一个商店视图页面来显示商家要执行的任务 在此页面上,每个任务对应一个视图块: 橙色块具有“任务列表警告”类 红色块具有“任务列表危险”类 有一个菜单链接显示此页面,我添加了2个徽章: 使用“任务徽章警告”类 使用“任务徽章危险”类 我想在页面上的菜单链接“徽章”中显示任务数: “任务标记警告”中“任务列表警告”类别的编号 “任务标识危险”中“任务列表危险”类别的编号 “存储”菜单是一个包含以下代
- 橙色块具有“任务列表警告”类
- 红色块具有“任务列表危险”类
- 使用“任务徽章警告”类
- 使用“任务徽章危险”类
- “任务标记警告”中“任务列表警告”类别的编号
- “任务标识危险”中“任务列表危险”类别的编号
<nav role="navigation" aria-labelledby="menu-page-boutique" id="menu-page-boutique" class="contextual-region">
<ul class="nav navbar-nav m-0">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fas fa-plus-circle fa-lg"></i> Gérer votre {{ store_entity.type.entity.label }}</a>
<ul class="dropdown-menu">
<li class="task">
<a href="/store/{{ store_entity.id }}/tasks" data-drupal-link-system-path="/store/{{ store_entity.id }}/tasks"><i class="fas fa-tasks fa-lg"></i> <b>Liste des tâches</b> <span class="badge badge-warning task-badge-warning">0</span> <span class="badge badge-danger task-badge-danger">0</span></a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/point-of-sale" data-drupal-link-system-path="/store/{{ store_entity.id }}/point-of-sale"><i class="fas fa-cash-register fa-lg"></i> Point de vente</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/migrate" data-drupal-link-system-path="/store/{{ store_entity.id }}/migrate"><i class="fas fa-exchange-alt fa-lg"></i> Migrer</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}" data-drupal-link-system-path="/store/{{ store_entity.id }}"><i class="fas fa-glasses fa-lg"></i> Voir</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/edit" data-drupal-link-system-path="/store/{{ store_entity.id }}/edit"><i class="fas fa-feather-alt fa-lg"></i> Modifier</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/delete" data-drupal-link-system-path="/store/{{ store_entity.id }}/delete"><i class="fas fa-trash-alt fa-lg"></i> Supprimer</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/translations" data-drupal-link-system-path="/store/{{ store_entity.id }}/translations"><i class="fas fa-globe fa-lg"></i> Traductions</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/members" data-drupal-link-system-path="/store/{{ store_entity.id }}/members"><i class="fas fa-sitemap fa-lg"></i> L'équipe</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/relationship" data-drupal-link-system-path="/store/{{ store_entity.id }}/relationship"><i class="fas fa-link fa-lg"></i> Relations</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/products" data-drupal-link-system-path="/store/{{ store_entity.id }}/products"><i class="fas fa-gift fa-lg"></i> Produits</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/promotions" data-drupal-link-system-path="/store/{{ store_entity.id }}/promotions"><i class="fas fa-percentage fa-lg"></i> Promotions</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/payment-gateways" data-drupal-link-system-path="/store/{{ store_entity.id }}/payment-gateways"><i class="fas fa-credit-card fa-lg"></i> Modes de paiement</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/shipping-methods" data-drupal-link-system-path="/store/{{ store_entity.id }}/shipping-methods"><i class="fas fa-truck fa-lg"></i> Modes de livraison</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/orders" data-drupal-link-system-path="/store/{{ store_entity.id }}/orders"><i class="fas fa-shopping-cart fa-lg"></i> Commandes</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/inventory" data-drupal-link-system-path="/store/{{ store_entity.id }}/inventory"><i class="fas fa-clipboard-list fa-lg"></i> Inventaire</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/reports" data-drupal-link-system-path="/store/{{ store_entity.id }}/reports"><i class="fas fa-calculator fa-lg"></i> Rapports de vente</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/like" data-drupal-link-system-path="/store/{{ store_entity.id }}/like"><i class="fas fa-heartbeat fa-lg"></i> Mentions j'aime</a>
</li>
<li>
<a href="/store/{{ store_entity.id }}/seo" data-drupal-link-system-path="/store/{{ store_entity.id }}/seo"><i class="fas fa-flag-checkered fa-lg"></i> Référencement</a>
</li>
</ul>
</li>
</ul>
</nav>
https://www.example.com/fr/store/ID_STORE
https://www.example.com/en/store/ID_STORE
https://www.example.com/fr/store/ID_STORE/*
https://www.example.com/en/store/ID_STORE/*