{% extends '@FoxHabbitBasis/Layout/layout.html.twig' %}
{% block content %}
<div class="search-results-container">
<header class="header-small bg-white">
<div class="container-fluid">
<div class="col-10 offset-1">
{% if searchQuery|default(null) %}
<h1 class="display-3 text-pre-line">{{ 'fulltext-seach.header.search-result' | trans }}</h1>
<div class="lead">{{ 'fulltext-seach.header.for' | trans }} "{{ searchQuery }}"</div>
{% else %}
<h1 class="display-3 text-pre-line">{{ 'fulltext-seach.header.search-page' | trans }}</h1>
{% endif %}
</div>
</div>
</header>
<div class="search-full-text-container col-10 offset-1 col-lg-6 offset-lg-3">
{% if error|default(null)%}
<div class="alert alert-danger">
{{ 'fulltext-seach.search-internal-error' | trans }}
</div>
{% endif %}
<form id="search" method="get" action="{{ document.getProperty('enableSearch') ? document.getProperty('enableSearch').getFullPath() : '' }}">
<div class="second-search-field form-group">
<label for="search-field">{{ 'fulltext-seach.search-form.search-field.label' | trans }}</label>
<input type="text" name="q" id="autocomplete" value="{{ searchQuery|default(null) }}" class="search-input form-control full-text-search-autocomplete">
<div class="search-suggestions-secondary d-none">
<div class="suggestions">
<h5>{{ pimcore_input('search_suggestions_title', {"placeholder": "Enter title for Search Suggestions"}) }}</h5>
<ul class="second-search-suggestions__list">
{% if editmode %}<li><a href="#">Search suggestions will appear here</a></li>{% endif %}
</ul>
</div>
</div>
</div>
<input type="submit" class="btn btn-secondary btn-search" name="submit" value={{ 'fulltext-seach.search-form.submit' | trans }}>
</form>
</div>
{# <div id="iframe-wrapper-boost"></div> #}
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
if (document.querySelector("#iframe-wrapper-boost")) return;
const params = new URLSearchParams(window.location.search);
const searchTerm = params.get("q");
if (!searchTerm) return;
// --- AI Overview Header ---
const header = document.createElement("div");
header.style.display = "flex";
header.style.alignItems = "center";
header.style.gap = "8px";
header.style.fontSize = "16px";
header.style.fontWeight = "500";
header.style.color = "#444";
header.style.margin = "40px auto 8px auto";
header.style.maxWidth = "900px";
header.style.paddingLeft = "4px";
const sparkle = document.createElement("span");
sparkle.innerHTML = "✦";
sparkle.style.color = "#8ab4f8";
const label = document.createElement("span");
label.textContent = "AI Overview";
header.appendChild(sparkle);
header.appendChild(label);
// --- Iframe Wrapper ---
const wrapper = document.createElement("div");
wrapper.id = "iframe-wrapper-boost";
wrapper.style.position = "relative";
wrapper.style.overflow = "hidden";
wrapper.style.maxHeight = "280px"; // smaller initial height
wrapper.style.border = "1px solid #ddd";
wrapper.style.borderRadius = "12px";
wrapper.style.boxShadow = "0 4px 12px rgba(0,0,0,0.08)";
wrapper.style.transition = "max-height 0.4s ease";
wrapper.style.margin = "0 auto 16px auto";
wrapper.style.width = "100%";
wrapper.style.maxWidth = "900px";
wrapper.style.backgroundColor = "#fff";
const iframe = document.createElement("iframe");
iframe.src = `https://smart-search-prototype.vercel.app/?q=${encodeURIComponent(searchTerm)}`;
iframe.id = "my-boost-iframe";
iframe.width = "100%";
iframe.style.height = "1000px";
iframe.style.border = "none";
iframe.style.borderRadius = "12px";
const gradient = document.createElement("div");
gradient.style.position = "absolute";
gradient.style.bottom = "0";
gradient.style.left = "0";
gradient.style.width = "100%";
gradient.style.height = "60px";
gradient.style.background = "linear-gradient(to bottom, rgba(255,255,255,0), #fff)";
gradient.style.pointerEvents = "none";
const button = document.createElement("button");
button.textContent = "Show more";
button.style.display = "block";
button.style.margin = "0 auto 40px auto";
button.style.background = "#f2f2f2";
button.style.border = "1px solid #ccc";
button.style.borderRadius = "9999px";
button.style.padding = "10px 24px";
button.style.fontSize = "15px";
button.style.color = "#333";
button.style.cursor = "pointer";
button.style.transition = "all 0.2s ease";
let expanded = false;
button.addEventListener("click", function () {
expanded = !expanded;
wrapper.style.maxHeight = expanded ? "1000px" : "280px";
gradient.style.display = expanded ? "none" : "block";
button.textContent = expanded ? "Show less" : "Show more";
});
wrapper.appendChild(iframe);
wrapper.appendChild(gradient);
const resultsContainer = document.querySelector("#results");
if (resultsContainer && resultsContainer.parentNode) {
resultsContainer.parentNode.insertBefore(header, resultsContainer);
resultsContainer.parentNode.insertBefore(wrapper, resultsContainer);
resultsContainer.parentNode.insertBefore(button, resultsContainer);
}
});
</script>
<section class="section">
{{ pimcore_area('breadcrumb', {type:'basisbundle-breadcrumb'}) }}
<div id="results"></div>
</section>
{% if searchHasResults|default(null) %}
<div class="col-11 offset-1">
<div class="info">
{{ 'fulltext-seach.search-list.result.results-from' | trans }} <span> {{ searchCurrentPageResultStart }} - {{ searchCurrentPageResultEnd }} </span> {{ 'fulltext-seach.search-list.result.of' | trans }} {{ searchTotalHits }}
</div>
</div>
{% endif %}
<div class="section p-0 container-fluid">
<div class="search-list">
{% if searchHasResults|default(null) %}
<ul class="search-results list-unstyled">
{% for i,searchResult in searchResults %}
<li class="search-result">
<div class="search-result-content col-12 col-sm-10 offset-sm-1 col-lg-6 offset-lg-3">
<a href="{{ searchResult.url }}" class="search-result-title">
{% if searchResult.title|default(null) %}
{{ searchResult.title | raw }}
{% endif %}
{% if searchResult.h1|default(null) %}
{{ searchResult.h1 | raw }}
{% endif %}
</a>
<p class="search-result-summary">{{ searchResult.summary | raw }}</p>
<a href="{{ searchResult.url }}" class="read-more"><i class="lorch-icon lorch-icon-next"></i>
{{ 'fulltext-seach.search-list.result.read-more' | trans }}
</a>
</div>
</li>
{% endfor %}
</ul>
{% set paginationVariables = full_text_search_pagination() %}
{% if searchAllPages > 1 %}
<div class="paginator">
{% if paginationVariables.currentSearchPage > 1 %}
<a class="previous icon-arrow-left"
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ paginationVariables.currentSearchPage - 1 }}"></a>
{% else %}
<a class="previous icon-arrow-left icon-arrow-left-disabled"
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ paginationVariables.currentSearchPage - 1 }}"></a>
{% endif %}
{% for i in paginationVariables.searchPageStart..paginationVariables.searchPageEnd %}
{% if i == paginationVariables.searchPageEnd %}
<a {{ paginationVariables.currentSearchPage == i ? 'class="active"' : '' }}
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ i }}#results">{{ i }}</a>
{% else %}
<a {{ paginationVariables.currentSearchPage == i ? 'class="active"' : '' }}
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ i }}#results">{{ i }}</a>
<span class="pagination-line">|</span>
{% endif %}
{% endfor %}
{% if paginationVariables.searchPageEnd > paginationVariables.currentSearchPage %}
<a class="next icon-arrow-right"
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ paginationVariables.currentSearchPage + 1 }}#results"></a>
{% else %}
<a class="next icon-arrow-right icon-arrow-right-disabled"
href="{{ paginationVariables.searchUrl }}{{ paginationVariables.searchUrlData }}&page={{ paginationVariables.currentSearchPage + 1 }}#results"></a>
{% endif %}
</div>
{% endif %}
{% else %}
{% if searchQuery|default(null) is not empty %}
<div class="section pt-0 no-results col-10 offset-1 col-lg-6 offset-lg-3">
<h5>{{ 'fulltext-seach.search-list.result.none' | trans }}</h5>
{% include '@LuceneSearch/List/Partial/suggestions.html.twig' %}
</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endblock %}