tntsearch.html.twig 1.9 KB

123456789101112131415161718192021222324252627282930
  1. {% set url = url|default(base_url|rtrim('/') ~ '/' ~ config.get('plugins.tntsearch.query_route', 's')|trim('/')) %}
  2. {% set limit = limit|default(config.get('plugins.tntsearch.limit', 20)) %}
  3. {% set snippet = snippet|default(config.get('plugins.tntsearch.snippet', 300)) %}
  4. {% set min = min|default(config.get('plugins.tntsearch.min', 3)) %}
  5. {% set search_type = search_type|default(config.get('plugins.tntsearch.search_type', 'auto')) %}
  6. {% set placeholder = placeholder|default('Search...') %}
  7. {% set live_update = in_page ? live_update|default(config.get('plugins.tntsearch.live_uri_update', 1)) : 0 %}
  8. {% set nojs_action = config.get('plugins.tntsearch.search_route', '/search')|trim('/') %}
  9. {% set options = { uri: url, limit: limit, snippet: snippet, min: min, in_page: in_page, live_update: live_update, search_type: search_type } %}
  10. <form role="form" class="tntsearch-form" action="{{ nojs_action }}" method="get">
  11. {% block tntsearch_input %}
  12. <div id="tntsearch-wrapper" class="form-group{{ dropdown ? ' tntsearch-dropdown' : '' }}">
  13. <input type="text" name="q" class="form-control form-input tntsearch-field{{ in_page ? ' tntsearch-field-inpage' : '' }}" data-tntsearch="{{ options|json_encode|e('html_attr') }}" placeholder="{{ placeholder }}" value="{{ not dropdown ? query|e : '' }}" autofocus>
  14. <span class="tntsearch-clear"{{ not query or dropdown ? ' style="display: none;"' : '' }}>&times;</span>
  15. </div>
  16. {% endblock %}
  17. <div class="tntsearch-results{{ in_page ? ' tntsearch-results-inpage' : '' }}">
  18. {% if tntsearch_results is defined and tntsearch_results is not empty and in_page %}
  19. {% include 'tntquery-ajax.html.twig' %}
  20. {% endif %}
  21. </div>
  22. {% if config.get('plugins.tntsearch.powered_by') %}
  23. <p class="tntsearch-powered-by">
  24. {{ "PLUGIN_TNTSEARCH.POWERED_BY"|t("<a href='https://github.com/trilbymedia/grav-plugin-tntsearch' target='_blank'>TNTSearch</a>")|raw }}
  25. </p>
  26. {% endif %}
  27. </form>