如何使用模板替换视图的字段?

时间:2019-03-27 10:08:41

标签: templates drupal twig drupal-8 drupal-views

我创建了一个Drupal 8视图,其中包含“用户ID”字段和“自定义文本”字段。

我视图的机器名称是:

menu_page_utilisateur

“自定义文本”字段使用令牌显示用户ID。

我创建了一个TWIG来替换“自定义文本”字段:

views-view-fields--menu_page_utilisateur.html.twig

可以,但是没有显示用户ID。

<ul class="nav nav-pills">
  <li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-plus-circle fa-lg"></i> Gérer votre compte</a>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="/user/{{ uid }}/tasks" data-drupal-link-system-path="/user/{{ uid }}/tasks"><i class="fas fa-tasks fa-lg"></i> <b>Liste des tâches</b></a>
      <a class="dropdown-item" href="/user/{{ uid }}" data-drupal-link-system-path="/user/{{ uid }}"><i class="fas fa-eye  fa-lg"></i> Voir</a>
      <a class="dropdown-item" href="/user/{{ uid }}/edit" data-drupal-link-system-path="/user/{{ uid }}/edit"><i class="fas fa-feather-alt fa-lg"></i> Modifier</a>
      <a class="dropdown-item" href="/user/{{ uid }}/cancel" data-drupal-link-system-path="/user/{{ uid }}/cancel"><i class="fas fa-trash-alt fa-lg"></i> Supprimer</a>
      <a class="dropdown-item" href="/user/{{ uid }}/subscription" data-drupal-link-system-path="/user/{{ uid }}/subscription"><i class="fas fa-certificate fa-lg"></i> Abonnements</a>
      <a class="dropdown-item" href="/user/{{ uid }}/orders" data-drupal-link-system-path="/user/{{ uid }}/orders"><i class="fas fa-shopping-cart fa-lg"></i> Commandes</a>
      <a class="dropdown-item" href="/user/{{ uid }}/payment-methods" data-drupal-link-system-path="/user/{{ uid }}/payment-methods"><i class="fas fa-credit-card fa-lg"></i> Modes de paiement</a>
      <a class="dropdown-item" href="/user/{{ uid }}/customer" data-drupal-link-system-path="/user/{{ uid }}/customer"><i class="fas fa-address-book fa-lg"></i> Carnet d'adresses</a>
      <a class="dropdown-item" href="/user/{{ uid }}/groupes" data-drupal-link-system-path="/user/{{ uid }}/groupes"><i class="fas fa-users fa-lg"></i> Groupes</a>
      <a class="dropdown-item" href="/user/{{ uid }}/stores" data-drupal-link-system-path="/user/{{ uid }}/stores"><i class="fas fa-shopping-bag fa-lg"></i> Boutiques</a>
      <a class="dropdown-item" href="/user/{{ uid }}/profils" data-drupal-link-system-path="/user/{{ uid }}/profiles"><i class="fas fa-address-card fa-lg"></i> Profils</a>
      <a class="dropdown-item" href="/user/{{ uid }}/like" data-drupal-link-system-path="/user/{{ uid }}/like"><i class="fas fa-heart fa-lg"></i> j'aimes</a>
      <a class="dropdown-item" href="/user/{{ uid }}/invitations" data-drupal-link-system-path="/user/{{ uid }}/invitations"><i class="fas fa-envelope-open fa-lg"></i> Invitations</a>
    </div>
  </li>
</ul>

enter image description here

如何仅替换“自定义文本”字段而不覆盖已使用的令牌?

enter image description here

0 个答案:

没有答案