entity-add-list.html.twig

Same filename in this branch
  1. 11.x core/themes/stable9/templates/content-edit/entity-add-list.html.twig
  2. 11.x core/themes/claro/templates/entity-add-list.html.twig
  3. 11.x core/modules/system/templates/entity-add-list.html.twig
Same filename and directory in other branches
  1. 10 core/themes/stable9/templates/content-edit/entity-add-list.html.twig
  2. 10 core/themes/claro/templates/entity-add-list.html.twig
  3. 10 core/modules/system/templates/entity-add-list.html.twig
  4. 9 core/themes/stable9/templates/content-edit/entity-add-list.html.twig
  5. 9 core/themes/seven/templates/entity-add-list.html.twig
  6. 9 core/themes/claro/templates/entity-add-list.html.twig
  7. 9 core/themes/stable/templates/content-edit/entity-add-list.html.twig
  8. 9 core/modules/system/templates/entity-add-list.html.twig
  9. 8.9.x core/themes/seven/templates/entity-add-list.html.twig
  10. 8.9.x core/themes/claro/templates/entity-add-list.html.twig
  11. 8.9.x core/themes/stable/templates/content-edit/entity-add-list.html.twig
  12. 8.9.x core/modules/system/templates/entity-add-list.html.twig
  13. main core/themes/stable9/templates/content-edit/entity-add-list.html.twig
  14. main core/themes/claro/templates/entity-add-list.html.twig
  15. main core/modules/system/templates/entity-add-list.html.twig

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.

See also

template_preprocess_entity_add_list()

1 theme call to entity-add-list.html.twig
EntityController::addPage in core/lib/Drupal/Core/Entity/Controller/EntityController.php
Displays add links for the available bundles.

File

core/themes/admin/templates/admin/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. <div class="panel gin-layer-wrapper">
  25. {% if title %}
  26. <h3 class="panel__title">{{ title }}</h3>
  27. {% endif %}
  28. <div{{ attributes.addClass('admin-list', 'panel__content', 'gin-layer-wrapper') }}>
  29. {% for bundle in bundles %}
  30. {#
  31. Add 'admin-item__link' class to the link attributes.
  32. This is needed for keeping the original attributes of the link's url.
  33. #}
  34. {% set bundle_attributes = bundle.add_link.url.getOption('attributes') ?: {} %}
  35. {% set link_attributes = create_attribute(bundle_attributes).addClass('admin-item__link') %}
  36. {% set description_id = bundle.add_link.text|clean_id ~ '-desc' %}
  37. <div{{ create_attribute({ class: item_classes }) }}>
  38. <a href="{{ bundle.add_link.url }}" title="{{ bundle.add_link.text }}" {{ link_attributes }}></a>
  39. <div class="admin-item__title"{% if bundle.description %} aria-details="{{ description_id }}"{% endif %}>
  40. {{ bundle.add_link.text }}
  41. </div>
  42. {# Don't print empty description wrapper if there is no description #}
  43. {% if bundle.description %}
  44. <div class="admin-item__description" id="{{ description_id }}">{{ bundle.description }}</div>
  45. {% endif %}
  46. </div>
  47. {% endfor %}
  48. </div>
  49. </div>
  50. {% elseif add_bundle_message is not empty %}
  51. <p>
  52. {{ add_bundle_message }}
  53. </p>
  54. {% endif %}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.