src/AppBundle/Resources/views/ObjectViews/search-results.html.twig line 1

Open in your IDE?
  1. {% extends '@FoxHabbitBasis/Layout/layout.html.twig' %}
  2. {% block content %}
  3.     <div class="search-results-container">
  4.         <header class="header-small bg-white">
  5.             <div class="container-fluid">
  6.                 <div class="col-10 offset-1">
  7.                     {% if searchQuery|default(null) %}
  8.                         <h1 class="display-3 text-pre-line">{{ 'fulltext-seach.header.search-result' | trans }}</h1>
  9.                         <div class="lead">{{ 'fulltext-seach.header.for' | trans }} "{{ searchQuery }}"</div>
  10.                     {% else %}
  11.                         <h1 class="display-3 text-pre-line">{{ 'fulltext-seach.header.search-page' | trans }}</h1>
  12.                     {% endif %}
  13.                 </div>
  14.             </div>
  15.         </header>
  16.         <div class="search-full-text-container col-10 offset-1 col-lg-6 offset-lg-3">
  17.             {% if error|default(null)%}
  18.                 <div class="alert alert-danger">
  19.                     {{ 'fulltext-seach.search-internal-error' | trans }}
  20.                 </div>
  21.             {% endif %}
  22.             <form id="search" method="get" action="{{ document.getProperty('enableSearch') ? document.getProperty('enableSearch').getFullPath() : '' }}">
  23.                 <div class="second-search-field form-group">
  24.                     <label for="search-field">{{ 'fulltext-seach.search-form.search-field.label' | trans }}</label>
  25.                     <input type="text" name="q" id="autocomplete" value="{{ searchQuery|default(null) }}" class="search-input form-control full-text-search-autocomplete">
  26.                     <div class="search-suggestions-secondary d-none">
  27.                     <div class="suggestions">
  28.                         <h5>{{ pimcore_input('search_suggestions_title', {"placeholder": "Enter title for Search Suggestions"}) }}</h5>
  29.                         <ul class="second-search-suggestions__list">
  30.                             {% if editmode %}<li><a href="#">Search suggestions will appear here</a></li>{% endif %}
  31.                         </ul>
  32.                     </div>
  33.                     </div>
  34.                 </div>
  35.                 <input type="submit" class="btn btn-secondary btn-search" name="submit" value={{ 'fulltext-seach.search-form.submit' | trans }}>
  36.             </form>
  37.         </div>
  38.         {# <div id="iframe-wrapper-boost"></div> #}
  39.         <script type="text/javascript">
  40.             document.addEventListener("DOMContentLoaded", function () {
  41.                 if (document.querySelector("#iframe-wrapper-boost")) return;
  42.                 const params = new URLSearchParams(window.location.search);
  43.                 const searchTerm = params.get("q");
  44.                 if (!searchTerm) return;
  45.                 // --- AI Overview Header ---
  46.                 const header = document.createElement("div");
  47.                 header.style.display = "flex";
  48.                 header.style.alignItems = "center";
  49.                 header.style.gap = "8px";
  50.                 header.style.fontSize = "16px";
  51.                 header.style.fontWeight = "500";
  52.                 header.style.color = "#444";
  53.                 header.style.margin = "40px auto 8px auto";
  54.                 header.style.maxWidth = "900px";
  55.                 header.style.paddingLeft = "4px";
  56.                 const sparkle = document.createElement("span");
  57.                 sparkle.innerHTML = "✦";
  58.                 sparkle.style.color = "#8ab4f8";
  59.                 const label = document.createElement("span");
  60.                 label.textContent = "AI Overview";
  61.                 header.appendChild(sparkle);
  62.                 header.appendChild(label);
  63.                 // --- Iframe Wrapper ---
  64.                 const wrapper = document.createElement("div");
  65.                 wrapper.id = "iframe-wrapper-boost";
  66.                 wrapper.style.position = "relative";
  67.                 wrapper.style.overflow = "hidden";
  68.                 wrapper.style.maxHeight = "280px"; // smaller initial height
  69.                 wrapper.style.border = "1px solid #ddd";
  70.                 wrapper.style.borderRadius = "12px";
  71.                 wrapper.style.boxShadow = "0 4px 12px rgba(0,0,0,0.08)";
  72.                 wrapper.style.transition = "max-height 0.4s ease";
  73.                 wrapper.style.margin = "0 auto 16px auto";
  74.                 wrapper.style.width = "100%";
  75.                 wrapper.style.maxWidth = "900px";
  76.                 wrapper.style.backgroundColor = "#fff";
  77.                 const iframe = document.createElement("iframe");
  78.                 iframe.src = `https://smart-search-prototype.vercel.app/?q=${encodeURIComponent(searchTerm)}`;
  79.                 iframe.id = "my-boost-iframe";
  80.                 iframe.width = "100%";
  81.                 iframe.style.height = "1000px";
  82.                 iframe.style.border = "none";
  83.                 iframe.style.borderRadius = "12px";
  84.                 const gradient = document.createElement("div");
  85.                 gradient.style.position = "absolute";
  86.                 gradient.style.bottom = "0";
  87.                 gradient.style.left = "0";
  88.                 gradient.style.width = "100%";
  89.                 gradient.style.height = "60px";
  90.                 gradient.style.background = "linear-gradient(to bottom, rgba(255,255,255,0), #fff)";
  91.                 gradient.style.pointerEvents = "none";
  92.                 const button = document.createElement("button");
  93.                 button.textContent = "Show more";
  94.                 button.style.display = "block";
  95.                 button.style.margin = "0 auto 40px auto";
  96.                 button.style.background = "#f2f2f2";
  97.                 button.style.border = "1px solid #ccc";
  98.                 button.style.borderRadius = "9999px";
  99.                 button.style.padding = "10px 24px";
  100.                 button.style.fontSize = "15px";
  101.                 button.style.color = "#333";
  102.                 button.style.cursor = "pointer";
  103.                 button.style.transition = "all 0.2s ease";
  104.                 let expanded = false;
  105.                 button.addEventListener("click", function () {
  106.                     expanded = !expanded;
  107.                     wrapper.style.maxHeight = expanded ? "1000px" : "280px";
  108.                     gradient.style.display = expanded ? "none" : "block";
  109.                     button.textContent = expanded ? "Show less" : "Show more";
  110.                 });
  111.                 wrapper.appendChild(iframe);
  112.                 wrapper.appendChild(gradient);
  113.                 const resultsContainer = document.querySelector("#results");
  114.                 if (resultsContainer && resultsContainer.parentNode) {
  115.                     resultsContainer.parentNode.insertBefore(header, resultsContainer);
  116.                     resultsContainer.parentNode.insertBefore(wrapper, resultsContainer);
  117.                     resultsContainer.parentNode.insertBefore(button, resultsContainer);
  118.                 }
  119.             });
  120.         </script>
  121.  
  122.         <section class="section">
  123.             {{ pimcore_area('breadcrumb', {type:'basisbundle-breadcrumb'}) }}
  124.             <div id="results"></div>
  125.         </section>
  126.         {% if searchHasResults|default(null) %}
  127.             <div class="col-11 offset-1">
  128.                 <div class="info">
  129.                     {{ 'fulltext-seach.search-list.result.results-from' | trans }} <span> {{ searchCurrentPageResultStart }} - {{ searchCurrentPageResultEnd }} </span> {{ 'fulltext-seach.search-list.result.of' | trans }} {{ searchTotalHits }}
  130.                 </div>
  131.             </div>
  132.         {% endif %}
  133.         <div class="section p-0 container-fluid">
  134.             <div class="search-list">
  135.                 {% if searchHasResults|default(null) %}
  136.                     <ul class="search-results list-unstyled">
  137.                         {% for i,searchResult in searchResults %}
  138.                             <li class="search-result">
  139.                                     <div class="search-result-content col-12 col-sm-10 offset-sm-1 col-lg-6 offset-lg-3">
  140.                                         <a href="{{ searchResult.url }}" class="search-result-title">
  141.                                             {% if searchResult.title|default(null) %}
  142.                                             {{ searchResult.title | raw }}
  143.                                             {% endif %}
  144.                                             {% if searchResult.h1|default(null) %}
  145.                                                 {{ searchResult.h1 | raw }}
  146.                                             {% endif %}
  147.                                         </a>
  148.                                     <p class="search-result-summary">{{ searchResult.summary | raw }}</p>
  149.                                         <a href="{{ searchResult.url }}" class="read-more"><i class="lorch-icon lorch-icon-next"></i>
  150.                                         {{ 'fulltext-seach.search-list.result.read-more' | trans }}
  151.                                     </a>
  152.                                     </div>
  153.                             </li>
  154.                         {% endfor %}
  155.                     </ul>
  156.                     {% set paginationVariables = full_text_search_pagination() %}
  157.                     {% if searchAllPages > 1 %}
  158.                         <div class="paginator">
  159.                             {% if paginationVariables.currentSearchPage > 1 %}
  160.                                 <a class="previous icon-arrow-left"
  161.                                    href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ paginationVariables.currentSearchPage - 1 }}"></a>
  162.                             {% else %}
  163.                                 <a class="previous icon-arrow-left icon-arrow-left-disabled"
  164.                                    href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ paginationVariables.currentSearchPage - 1 }}"></a>
  165.                             {% endif %}
  166.                             {% for i in paginationVariables.searchPageStart..paginationVariables.searchPageEnd %}
  167.                                 {% if i == paginationVariables.searchPageEnd %}
  168.                                     <a {{ paginationVariables.currentSearchPage == i ? 'class="active"' : '' }}
  169.                                         href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ i }}#results">{{ i }}</a>
  170.                                 {% else %}
  171.                                     <a {{ paginationVariables.currentSearchPage == i ? 'class="active"' : '' }}
  172.                                         href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ i }}#results">{{ i }}</a>
  173.                                     <span class="pagination-line">|</span>
  174.                                 {% endif %}
  175.                             {% endfor %}
  176.                             {% if paginationVariables.searchPageEnd > paginationVariables.currentSearchPage %}
  177.                                 <a class="next icon-arrow-right"
  178.                                    href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ paginationVariables.currentSearchPage + 1 }}#results"></a>
  179.                             {% else %}
  180.                                 <a class="next icon-arrow-right icon-arrow-right-disabled"
  181.                                    href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&amp;page={{ paginationVariables.currentSearchPage + 1 }}#results"></a>
  182.                             {% endif %}
  183.                         </div>
  184.                     {% endif %}
  185.                 {% else %}
  186.                     {% if searchQuery|default(null) is not empty %}
  187.                         <div class="section pt-0 no-results col-10 offset-1 col-lg-6 offset-lg-3">
  188.                             <h5>{{ 'fulltext-seach.search-list.result.none' | trans }}</h5>
  189.                             {% include '@LuceneSearch/List/Partial/suggestions.html.twig' %}
  190.                         </div>
  191.                     {% endif %}
  192.                 {% endif %}
  193.             </div>
  194.         </div>
  195.     </div>
  196. {% endblock %}