block_search_result.html.twig 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. {% extends sonata_block.templates.block_base %}
  8. {% block block %}
  9. {% set show_empty_boxes = sonata_admin.adminPool.container.getParameter('sonata.admin.configuration.global_search.empty_boxes') %}
  10. {% set visibility_class = '' %}
  11. {% if pager and not pager.getResults()|length %}
  12. {% set visibility_class = 'sonata-search-result-' ~ show_empty_boxes %}
  13. {% endif %}
  14. <div class="col-lg-4 col-md-6 search-box-item {{ visibility_class }}">
  15. <div class="box box-solid box-primary{{ visibility_class }}">
  16. <div class="box-header with-border {{ visibility_class }}">
  17. {% set icon = settings.icon|default('') %}
  18. {{ icon|raw }}
  19. <h3 class="box-title">
  20. {{ admin.label|trans({}, admin.translationdomain) }}
  21. </h3>
  22. <div class="box-tools pull-right">
  23. {% if pager and pager.getNbResults() > 0 %}
  24. <span class="badge bg-light-blue">{{ pager.getNbResults() }}</span>
  25. {% elseif admin.hasRoute('create') and admin.hasAccess('create') %}
  26. <a href="{{ admin.generateUrl('create') }}" class="btn btn-box-tool">
  27. <i class="fa fa-plus" aria-hidden="true"></i>
  28. </a>
  29. {% endif %}
  30. {% if admin.hasRoute('list') and admin.hasAccess('list') %}
  31. <a href="{{ admin.generateUrl('list') }}" class="btn btn-box-tool">
  32. <i class="fa fa-list" aria-hidden="true"></i>
  33. </a>
  34. {% endif %}
  35. </div>
  36. </div>
  37. {% if pager and pager.getResults()|length %}
  38. <div class="box-body no-padding">
  39. <ul class="nav nav-stacked sonata-search-result-list">
  40. {% for result in pager.getResults() %}
  41. {% set link = admin.getSearchResultLink(result) %}
  42. {% if link %}
  43. <li><a href="{{ link }}">{{ admin.toString(result) }}</a></li>
  44. {% else %}
  45. <li><a>{{ admin.toString(result) }}</a></li>
  46. {% endif %}
  47. {% endfor %}
  48. </ul>
  49. </div>
  50. {% else %}
  51. <div class="box-body">
  52. <p>
  53. <em>{{ 'no_results_found'|trans({}, 'SonataAdminBundle') }}</em>
  54. </p>
  55. </div>
  56. {% endif %}
  57. </div>
  58. </div>
  59. {% endblock %}