MODIFY searcher

This commit is contained in:
2025-08-13 08:58:35 +00:00
parent d800c2cbc2
commit 223bca3767
8 changed files with 101 additions and 53 deletions

View File

@ -16,6 +16,7 @@ Timber::render( 'templates/page.twig', $context );*/
$context = Timber::context();
$timber_post = Timber::get_post();
$context['post'] = $timber_post;
$context['search_query'] = get_search_query();
//Timber::render( array( 'templates/page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
@ -24,6 +25,9 @@ $parent = get_post($timber_post->post_parent);
if ($parent && $parent->post_name === 'contactos') {
// Para subpáginas de contactos, usar page-contactos.twig
Timber::render('templates/page-contactos.twig', $context);
} elseif ($parent && $parent->post_name === 'servicios-privados' || $parent && $parent->post_name === 'servicios-publicos') {
// Para subpáginas de servicios privados, usar page-servicio-individual.twig
Timber::render('templates/single-servicios.twig', $context);
} else {
// Para el resto, usar la lógica original
Timber::render(array('templates/page-' . $timber_post->post_name . '.twig'), $context);

View File

@ -9,10 +9,6 @@ use Timber\Timber;
$templates = [ 'templates/search.twig', 'templates/archive.twig', 'templates/index.twig' ];
$context = Timber::context(
[
'title' => 'Search results for ' . get_search_query(),
]
);
$context = Timber::context([]);
Timber::render( $templates, $context );

View File

@ -1,16 +1,18 @@
<button class="btn btn-light" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">
<i class="bi bi-search"></i>
</button>
<section class="section-search">
<button class="btn btn-light" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">
<i class="bi bi-search"></i>
</button>
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasTopLabel">Búsqueda</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<form class="d-flex mt-3" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"/>
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
<div class="offcanvas offcanvas-top mt-3" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel" style="max-height: 18vh;">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasTopLabel">Búsqueda</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<form class="d-flex mt-3" role="search" method="get" action="/">
<input class="form-control me-2" type="search" name="s" placeholder="Buscar..." aria-label="Search"/>
<button class="btn btn-primary-cnt" type="submit">Buscar</button>
</form>
</div>
</div>
</section>

View File

@ -1,43 +1,60 @@
{% if posts.pagination.pages is not empty %}
<nav class="pagination-block">
<nav class="pagination-block d-flex justify-content-center">
<ul class="pagination">
{# First #}
{% if (posts.pagination.pages|first) and posts.pagination.pages|first.current != true %}
<li class="first btn">
<a href="{{ posts.pagination.pages|first.link }}">First</a>
<li class="first mx-2 border border-0">
<a href="{{ posts.pagination.pages|first.link }}" class="text-decoration-none btn-primary-cnt btn-pagination-position btn-page-hover">Inicio</a>
</li>
{% else %}
<li class="first btn disabled"><button disabled>First</button></li>
<li class="first disabled mx-2 border border-0" >
<button disabled class="btn-secondary-cnt btn-pagination-position btn-no-hover">Inicio</button>
</li>
{% endif %}
{# Previous #}
{% if posts.pagination.prev %}
<li class="prev btn"><a href="{{ posts.pagination.prev.link }}">Previous</a></li>
<li class="prev mx-2 border border-0">
<a href="{{ posts.pagination.prev.link }}" class="text-decoration-none btn-primary-cnt btn-pagination-position btn-page-hover">Anterior</a>
</li>
{% else %}
<li class="prev btn disabled"><button disabled>Previous</button></li>
<li class="prev disabled mx-2 border border-0">
<button disabled class="btn-secondary-cnt btn-pagination-position btn-no-hover">Anterior</button>
</li>
{% endif %}
{# Pages #}
{% for page in posts.pagination.pages %}
{% if page.link %}
<li><a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a></li>
<li class="mx-2 btn-pagination-position">
<a href="{{ page.link }}" class="{{ page.class }} text-decoration-none btn-page-hover" >{{ page.title }}</a>
</li>
{% else %}
<li class="current"><span class="{{ page.class }}">{{ page.title }}</span></li>
<li class="current mx-2 btn-pagination-position">
<span class="{{ page.class }}">{{ page.title }}</span>
</li>
{% endif %}
{% endfor %}
{# Next #}
{% if posts.pagination.next %}
<li class="next btn"><a href="{{ posts.pagination.next.link }}">Next</a></li>
<li class="next mx-2 border border-0">
<a href="{{ posts.pagination.next.link }}" class="text-decoration-none btn-primary-cnt btn-pagination-position btn-page-hover">Siguiente</a>
</li>
{% else %}
<li class="next btn disabled"><button disabled>Next</button></li>
<li class="next disabled mx-2 border border-0">
<button disabled class="btn-secondary-cnt btn-pagination-position btn-no-hover">Siguiente</button>
</li>
{% endif %}
{# Last #}
{% if (posts.pagination.pages|last) and posts.pagination.pages|last.current != true %}
<li class="last btn"><a href="{{ posts.pagination.pages|last.link }}">Last</a></li>
<li class="last mx-2 border border-0">
<a href="{{ posts.pagination.pages|last.link }}" class="text-decoration-none btn-primary-cnt btn-pagination-position btn-page-hover">Última</a></li>
{% else %}
<li class="last btn disabled"><button disabled>Last</button></li>
<li class="last disabled mx-2 border border-0">
<button disabled class="btn-secondary-cnt btn-pagination-position btn-no-hover">Última</button>
</li>
{% endif %}
</ul>
</nav>

View File

@ -6,7 +6,7 @@
{{
post.excerpt({
words: 5,
read_more: 'Keep reading'
read_more: 'Sigue leyendo'
})
}}
</p>

View File

@ -1,9 +1,30 @@
<article class="tease tease-{{ post.type }}" id="tease-{{ post.id }}">
{% block content %}
<h2 class="h2"><a href="{{ post.link }}">{{ post.title }}</a></h2>
<p>{{ post.excerpt }}</p>
{% if post.thumbnail %}
<img src="{{ post.thumbnail.src }}" />
{% endif %}
{% endblock %}
<article class="tease tease-{{ post.type }} border border-black rounded my-3 p-2 position-relative"
id="tease-{{ post.id }}"
style="padding-bottom: 65px !important;">
<div class="row align-items-center section-tease">
<!-- Columna izquierda: título y excerpt -->
<div class="col">
<h2 class="h2">
<a href="{{ post.link }}"
class="text-decoration-none text-dark link-underline-animate">
{{ post.title }}</a>
</h2>
<p>{{ post.excerpt({
words: 50,
read_more: ''
})
}}</p>
<a href="{{ post.link }}"
class="btn position-absolute btn-secondary-cnt"
style="position: absolute; bottom: 15px; right: 15px; z-index: 10;"
>Sigue leyendo...</a>
</div>
<!-- Columna derecha: imagen (si existe) -->
{% if post.thumbnail %}
<div class="col-auto text-end">
<img src="{{ post.thumbnail.src }}" style="max-height: 100px;" alt="{{ post.title }}" class="img-fluid ms-auto d-block" />
</div>
{% endif %}
</div>
</article>

View File

@ -16,7 +16,9 @@
<!-- Right side: RRSS -->
<div class="col d-flex justify-content-end">
{% include "partials/btn-search.twig" with {'items': menu.get_items} %}
<div class="btn-group m-1" role="group" aria-label="First group">
{% for red in redes_sociales %}
<a href="{{ red.url }}" class="btn btn-outline-dark btn-sm pt-0" target="_blank" rel="noopener noreferrer">

View File

@ -2,17 +2,23 @@
{% extends 'layouts/base.twig' %}
{% block content %}
<div class="content-wrapper">
{% for post in posts %}
{% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %}
{% endfor %}
<section class="search-canvas ">
<p class="mb-5 position-relative fs-4 fw-bold sp-module-title">BÚSQUEDA</p>
<p>Resultados de búsqueda para: "{{ search_query }}"</p>
<div class="content-wrapper">
{% for post in posts %}
{% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %}
{% endfor %}
{% include 'partials/pagination.twig' with {
pagination: posts.pagination({
show_all: false,
mid_size: 3,
end_size: 2
})
} %}
</div>
</section>
{% include 'partials/pagination.twig' with {
pagination: posts.pagination({
show_all: false,
mid_size: 3,
end_size: 2
})
} %}
</div>
{% endblock %}