You are here

entity-add-list.html.twig in Drupal 10

Theme override to present a list of available bundles.

Available variables:

  • bundles: A list of bundles, each with the following properties:

    • label: Bundle label.
    • description: Bundle description.
    • add_link: \Drupal\Core\Link link instance to create an entity of this bundle.
  • add_bundle_message: The message shown when there are no bundles. Only available if the entity type uses bundle entities.

File

core/themes/claro/templates/entity-add-list.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override to present a list of available bundles.
  5. *
  6. * Available variables:
  7. * - bundles: A list of bundles, each with the following properties:
  8. * - label: Bundle label.
  9. * - description: Bundle description.
  10. * - add_link: \Drupal\Core\Link link instance to create an entity of this
  11. * bundle.
  12. * - add_bundle_message: The message shown when there are no bundles. Only
  13. * available if the entity type uses bundle entities.
  14. *
  15. * @see template_preprocess_entity_add_list()
  16. */
  17. #}
  18. {%
  19. set item_classes = [
  20. 'admin-item',
  21. ]
  22. %}
  23. {% if bundles is not empty %}
  24. <dl{{ attributes.addClass('admin-list') }}>
  25. {% for bundle in bundles %}
  26. {#
  27. Add 'admin-item__link' class to the link attributes.
  28. This is needed for keeping the original attributes of the link's url.
  29. #}
  30. {% set bundle_attributes = bundle.add_link.url.getOption('attributes') ?: {} %}
  31. {% set link_attributes = create_attribute(bundle_attributes).addClass('admin-item__link') %}
  32. <div{{ create_attribute({ class: item_classes }) }}>
  33. <dt class="admin-item__title">
  34. <a href="{{ bundle.add_link.url }}"{{ link_attributes|without('href') }}>
  35. {{ bundle.add_link.text }}
  36. </a>
  37. </dt>
  38. {# Don't print empty description wrapper if there is no description #}
  39. {% if bundle.description %}
  40. <dd class="admin-item__description">{{ bundle.description }}</dd>
  41. {% endif %}
  42. </div>
  43. {% endfor %}
  44. </dl>
  45. {% elseif add_bundle_message is not empty %}
  46. <p>
  47. {{ add_bundle_message }}
  48. </p>
  49. {% endif %}