refactorizar

This commit is contained in:
2025-10-14 15:08:21 +00:00
parent d1e5638ed2
commit 4abf91910f
10 changed files with 367 additions and 349 deletions

View File

@ -8,6 +8,6 @@ $context = Timber::context();
// WordPress ya tiene la paginación correcta en la query
$context['posts_opinion'] = Timber::get_posts();
error_log('✅ Archive opinion - Posts: ' . count($context['posts_opinion']));
error_log('✅ archive-opinion - Posts: ' . count($context['posts_opinion']));
Timber::render('templates/page-opinion.twig', $context);

View File

@ -15,4 +15,4 @@ use Timber\Timber;
require_once __DIR__ . '/vendor/autoload.php';
Timber::init();
new StarterSite();
$site = new StarterSite();

View File

@ -25,7 +25,7 @@ $parent = get_post($timber_post->post_parent);
$cast_subpagina_servicios = ($parent && ($parent->post_name === 'servicios-privados' || $parent->post_name === 'servicios-publicos'));
$eusk_subpagina_zerbitzu = ($parent && ($parent->post_name === 'zerbitzu-pribatuak' || $parent->post_name === 'zerbitzu-publikoak'));
$subpagina_industria = ($parent && ($parent->post_name === 'industria'));
// Verificar si es una página padre de servicios
$slug_actual = $timber_post->post_name;
//error_log('✅ (page.php) Slug actual: ' . $slug_actual);
$pagina_servicios = ($slug_actual === 'servicios-privados' || $slug_actual === 'servicios-publicos' || $slug_actual === 'zerbitzu-pribatuak' || $slug_actual === 'zerbitzu-publikoak');
@ -35,14 +35,21 @@ if ($parent && ($parent->post_name === 'contactos' || $parent->post_name === 'ko
// subpáginas de contactos
Timber::render('templates/page-contactos.twig', $context);
} elseif ($pagina_servicios) {
//error_log('✅ (page.php) Página padre de servicios: ' . $slug_actual);
error_log('✅ (page.php) Página Servicios: ' . $slug_actual);
Timber::render('templates/page-servicios.twig', $context);
} elseif ( $cast_subpagina_servicios || $eusk_subpagina_zerbitzu ) {
error_log('✅ (page.php) Página "Servicios": ' . $parent->post_name);
error_log('✅ (page.php) Página "single-servicios": ' . $parent->post_name);
Timber::render('templates/single-servicios.twig', $context);
} elseif ( $subpagina_industria ) {
//error_log('✅ (page.php) Página "Industria": ' . $parent->post_name);
Timber::render('templates/single-industria.twig', $context);
} elseif ( $slug_actual === 'noticias' || $slug_actual === 'berriak') {
$context['posts_noticias'] = Timber::get_posts(array(
'post_type' => 'post',
'cat' => get_cat_ID('noticias'), // Obtiene los posts de la categoría "noticias"
));
//error_log('✅ (page.php) Página noticias - Posts: ' . count($context['posts_noticias']));
Timber::render('templates/page-noticias.twig', $context);
} else {
error_log('✅ (page.php) Página: ' . $parent->post_name);
Timber::render(array('templates/page-' . $timber_post->post_name . '.twig'), $context);

View File

@ -44,39 +44,6 @@ class StarterSite extends Site {
}
});
//Arreglar paginación para post type "opinion"
add_action('init', function() {
// Asegurarse de que opinion tenga archive habilitado
global $wp_post_types;
if (isset($wp_post_types['opinion'])) {
$wp_post_types['opinion']->has_archive = true;
}
});
//Añadir regla de rewrite personalizada para paginación de "opinion"
add_action('init', function() {
add_rewrite_rule(
'^opinion/page/([0-9]{1,})/?$',
'index.php?post_type=opinion&paged=$matches[1]',
'top'
);
// Si usas multiidioma, añade también para cada idioma
add_rewrite_rule(
'^([a-z]{2})/opinion/page/([0-9]{1,})/?$',
'index.php?lang=$matches[1]&post_type=opinion&paged=$matches[2]',
'top'
);
}, 10);
//Forzar flush de rewrite rules (solo una vez)
add_action('init', function() {
if (get_option('opinion_pagination_flushed') !== 'yes') {
flush_rewrite_rules();
update_option('opinion_pagination_flushed', 'yes');
}
}, 999);
/** POST "QUÉ ES LA CNT" */
// Previene borrar el post "Qué es la cnt" porque forma parte del menú //
$ids_especiales = [10982, 4791, 10981];
@ -291,80 +258,73 @@ class StarterSite extends Site {
return $file_types;
}
//section "portada> ENLACES"
private function getBotonesEnlaces($page_id = null) {
// Añadir idiomas de Polylang
private function getPolylangData() {
$polylang_data = array();
if (function_exists('pll_the_languages')) {
// Idiomas con toda la información
$polylang_data['languages'] = pll_the_languages(array(
'raw' => 1,
'hide_if_no_translation' => 0,
'show_flags' => 1,
'show_names' => 1
));
// Información del idioma actual
$polylang_data['current_language'] = pll_current_language();
$polylang_data['current_language_name'] = pll_current_language('name');
$polylang_data['default_language'] = pll_default_language();
if (is_null($page_id)) {
$page_id = get_the_ID();
// Si estamos en euskera, obtener la página en español
if (pll_current_language() == 'eu') {
$spanish_page_id = pll_get_post($page_id, 'es');
$page_id = $spanish_page_id ?: $page_id;
// DEBUG: Escribir en el log de errores
//error_log('Languages: ' . print_r($polylang_data['languages'], true));
//error_log('Current language: ' . $polylang_data['current_language']);
//error_log('Default language: ' . $polylang_data['default_language']);
// URLs de home para cada idioma
$polylang_data['home_urls'] = array();
foreach ($polylang_data['languages'] as $lang) {
$polylang_data['home_urls'][$lang['slug']] = $lang['url'];
}
}
$botones = [];
for ($i = 1; $i <= 4; $i++) {
$imagen = get_field('imagen_boton_' . $i, $page_id);
$enlace = get_field('enlace_boton_' . $i, $page_id);
$botones[] = [
'imagen' => $imagen,
'enlace' => $enlace,
];
}
return $botones;
return $polylang_data;
}
//Get POSTS with category "noticias"
private function getPostsNews() {
/* TEMP. DELETE... */
private function getAllPostsNews() {
$post = Timber::get_post();
//if ($post) { error_log('✅ Este es el ID Página news: ' . $post->ID);}
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// $post = Timber::get_post();
// //if ($post) { error_log('✅ Este es el ID Página news: ' . $post->ID);}
// $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//84=portada CAST & 331= portada EUSKARA
if ( $post && ( $post->ID === 84 || $post->ID === 331) ) {
return [
'posts' => Timber::get_posts([
'post_type' => 'post',
'posts_per_page' => -1,
'category_name' => 'noticias',
'post_status' => 'publish'
]),
'pagination' => null
];
//8=noticias CAST & 339= noticias EUSKARA
} elseif ( $post && ( $post->ID === 8 || $post->ID === 339) ) {
global $wp_query;
$temp_query = $wp_query;
$wp_query = new \WP_Query([
'post_type' => 'post',
'category_name' => 'noticias',
'posts_per_page' => 10,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
]);
// //8=noticias CAST & 339= noticias EUSKARA
// if ( $post && ( $post->ID === 8 || $post->ID === 339) ) {
// global $wp_query;
// $temp_query = $wp_query;
// $wp_query = new \WP_Query([
// 'post_type' => 'post',
// 'category_name' => 'noticias',
// 'posts_per_page' => 10,
// 'post_status' => 'publish',
// 'orderby' => 'date',
// 'order' => 'DESC',
// 'paged' => $paged,
// ]);
$posts = Timber::get_posts(); // Lee de la query global que acabamos de crear
$pagination = new \Timber\Pagination();
$wp_query = $temp_query; // Restaurar query original
// $posts = Timber::get_posts(); // Lee de la query global que acabamos de crear
// $pagination = new \Timber\Pagination();
// $wp_query = $temp_query; // Restaurar query original
return $posts;
// return $posts;
// }
}
//error_log('❌ getPostsNews - No coincide con ninguna página');
return [
'posts' => [],
'pagination' => null
];
// //error_log('❌ getPostsNews - No coincide con ninguna página');
// return [
// 'posts' => [],
// 'pagination' => null
// ];
}
private function getIconsRRSS() {
@ -445,123 +405,6 @@ class StarterSite extends Site {
return ['posts' => [], 'pagination' => null];
}
private function getOpinion() {
$post = Timber::get_post();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//84=portada CAST & 331= portada EUSKARA
if ( $post && ( $post->ID === 84 || $post->ID === 331) ) {
return Timber::get_posts([
'post_type' => 'opinion',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
//2011=opinion CAST & 10962=opinion EUSKARA
} elseif ( $post && ($post->ID === 2011 || $post->ID === 10962) ) {
global $wp_query;
$temp_query = $wp_query;
$wp_query = new \WP_Query([
'post_type' => 'opinion',
'posts_per_page' => 10,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
]);
// Timber::get_posts() SIN PARÁMETROS usa la query global ($wp_query)
$posts = Timber::get_posts(); // Lee de la query global que acabamos de crear
$pagination = new \Timber\Pagination($wp_query->max_num_pages);
$wp_query = $temp_query; // Restaurar query original
return $posts;
}
return ['posts' => [], 'pagination' => null];
}
//Get portada > Campañas
private function getCampanaArticles() {
return Timber::get_posts([
'post_type' => 'campana',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
//Get portada > Conflictos (category)
private function getConflictsCategory() {
return Timber::get_posts([
'post_type' => 'post',
'posts_per_page' => 1,
'post_status' => 'publish',
'category_name' => 'conflictos laborales',
'orderby' => 'date',
'order' => 'DESC'
]);
}
public function generar_embed_universal($url) {
if (empty($url)) {
return false;
}
// YouTube
if (strpos($url, 'youtube.com') !== false || strpos($url, 'youtu.be') !== false) {
//error_log('es un vídeo de youtube'); // Debug
preg_match('/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/', $url, $matches);
if (!empty($matches[1])) {
$embed_data = [
'platform' => 'youtube',
'embed_url' => 'https://www.youtube.com/embed/' . $matches[1] . '?rel=0&modestbranding=1',
'thumbnail_url' => 'https://img.youtube.com/vi/' . $matches[1]. '/hqdefault.jpg',
'allow' => 'autoplay; encrypted-media; picture-in-picture'
];
//error_log('Embed URL generada: ' . $embed_data['embed_url']);
return $embed_data;
} else {
error_log('No se pudo extraer ID de YouTube');
}
}
// Vimeo
if (strpos($url, 'vimeo.com') !== false) {
preg_match('/vimeo\.com\/(\d+)/', $url, $matches);
if (!empty($matches[1])) {
return [
'platform' => 'vimeo',
'embed_url' => 'https://player.vimeo.com/video/' . $matches[1] . '?title=0&byline=0&portrait=0',
'allow' => 'autoplay; fullscreen; picture-in-picture'
];
}
}
// Si no se reconoce la plataforma
return [
'platform' => 'generic',
'embed_url' => $url,
'allow' => 'fullscreen'
];
}
// Hacer función disponible en Twig
public function add_videos_embed_to_twig ($twig) {
//error_log('Añadiendo función generar_embed a Twig'); // Debug
$twig->addFunction(new \Twig\TwigFunction('generar_embed', [$this, 'generar_embed_universal']));
return $twig;
}
private function getPaginasAcerca() {
return Timber::get_posts([
'post_type' => 'acerca',
@ -572,7 +415,6 @@ class StarterSite extends Site {
]);
}
//Obtiene los "Documentos"
private function getDocumentos() {
$args = ([
@ -615,7 +457,6 @@ class StarterSite extends Site {
return $documentos;
}
/** Obetiene campos de "Enlaces" */
private function getEnlaces() {
$grupos = [];
@ -680,9 +521,8 @@ class StarterSite extends Site {
return $grupos;
}
/** Servicios públicos y privados */
private function getSubpaginasServicios() {
//Which paths is for 'servicios'
public function whichPathIs() {
$current_post = get_post();
$slug_actual = $current_post->post_name;
@ -700,15 +540,38 @@ class StarterSite extends Site {
$path = 'ekintza-sindikala/zerbitzu-pribatuak';
$tipo = 'pribatuak';
} else {
return [
'path' => null,
'tipo' => null,
'found' => false
];
}
return [
'path' => $path,
'tipo' => $tipo,
'found' => true
];
}
/** Servicios públicos y privados */
private function getSubpaginasServicios() {
$pathInfo = $this->whichPathIs();
// Si no encontramos una página válida, retornar vacío
if (!$pathInfo['found']) {
return [
'subpaginas' => [],
'pagination_Servicios' => null
];
}
$pag_servicios = get_page_by_path($path);
$full_path = $pathInfo['path'];
$pag_servicios = get_page_by_path($full_path);
if (!$pag_servicios) {
error_log("🔴 Página '$path' no encontrada.");
error_log("🔴 Página '$pathTipo.$path' no encontrada.");
return [
'subpaginas' => [],
'pagination_Servicios' => null
@ -734,7 +597,7 @@ class StarterSite extends Site {
$subpaginas = Timber::get_posts(); // Timber::get_posts() SIN PARÁMETROS usa la query global ($wp_query)
foreach ($subpaginas as $pagina) {
$pagina->thumbnail = get_the_post_thumbnail_url($pagina->ID);
$pagina->tipo_servicio = $tipo;
$pagina->tipo_servicio = $pathInfo['tipo'];
}
$pagination = new \Timber\Pagination($wp_query->max_num_pages); // Crear objeto de paginación
@ -744,7 +607,6 @@ class StarterSite extends Site {
}
//Campos de contactos
public function getContactoFields() {
$post = Timber::get_post();
@ -769,57 +631,6 @@ class StarterSite extends Site {
}
// Excluir páginas de la búsqueda
public function exclude_pages_from_search($query) {
if (!is_admin() && $query->is_main_query() && $query->is_search()) {
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'exclude_from_search',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'exclude_from_search',
'value' => '1',
'compare' => '!='
)
));
}
}
// Añadir idiomas de Polylang
private function getPolylangData() {
$polylang_data = array();
if (function_exists('pll_the_languages')) {
// Idiomas con toda la información
$polylang_data['languages'] = pll_the_languages(array(
'raw' => 1,
'hide_if_no_translation' => 0,
'show_flags' => 1,
'show_names' => 1
));
// Información del idioma actual
$polylang_data['current_language'] = pll_current_language();
$polylang_data['current_language_name'] = pll_current_language('name');
$polylang_data['default_language'] = pll_default_language();
// DEBUG: Escribir en el log de errores
//error_log('Languages: ' . print_r($polylang_data['languages'], true));
//error_log('Current language: ' . $polylang_data['current_language']);
//error_log('Default language: ' . $polylang_data['default_language']);
// URLs de home para cada idioma
$polylang_data['home_urls'] = array();
foreach ($polylang_data['languages'] as $lang) {
$polylang_data['home_urls'][$lang['slug']] = $lang['url'];
}
}
return $polylang_data;
}
private function getPostIndustry() {
$pag_industry = get_page_by_path('accion-sindical/industria');
@ -848,29 +659,203 @@ class StarterSite extends Site {
return $subpaginas;
}
private function getListContacts() {
$contactos_page = Timber::get_posts([
'post_type' => 'page',
'name' => 'kontaktua', // slug en euskera
'posts_per_page' => 1
])[0] ?? null;
// Si no encuentra en euskera, busca en castellano
if (!$contactos_page) {
$contactos_page = Timber::get_posts([
'post_type' => 'page',
'name' => 'contactos', // slug en castellano
'posts_per_page' => 1
])[0] ?? null;
}
return $contactos_page ? Timber::get_posts([
'post_type' => 'page',
'post_parent' => $contactos_page->ID,
'orderby' => 'menu_order',
'order' => 'ASC'
]) : [];
}
//Global variables
public function add_global_context($context) {
// GLobales
$context['logos_header'] = $this->getLogosHeader();
$context['redes_sociales'] = $this->getIconsRRSS();
$context['listContacts'] = $this->getListContacts();
$context['footer_1'] = get_field('footer_text_1', 'option');
$context['footer_2'] = get_field('footer_text_2', 'option');
$context['botones_imagen'] = $this->getBotonesEnlaces();
$context['redes_sociales'] = $this->getIconsRRSS();
$context['logos_header'] = $this->getLogosHeader();
$context['posts_opinion'] = $this->getOpinion();
$context['posts_campana'] = $this->getCampanaArticles();
//Otras páginas
$context['videos'] = $this->getVideos();
$context['paginas_acerca'] = $this->getPaginasAcerca();
$context['posts_conflicts'] = $this->getConflictsCategory();
$context['documentos'] = $this->getDocumentos();
$context['enlaces'] = $this->getEnlaces();
$context['contacto_info'] = $this->getContactoFields();
$context['posts_industry'] = $this->getPostIndustry();
$context['posts_noticias'] = $this->getPostsNews();
$context['subpaginas_servicios'] = $this->getSubpaginasServicios();
$context['videos'] = $this->getVideos();
//otros
$context = array_merge($context, $this->getPolylangData());
return $context;
}
/**
* Funciones public 'Template-Portada'
*/
public function getLastsPostsNews() {
return Timber::get_posts([
'post_type' => 'post',
'category_name' => 'noticias',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
public function getBotonesEnlaces($page_id = null) {
if (is_null($page_id)) {
$page_id = get_the_ID();
// Si estamos en euskera, obtener la página en español
if (pll_current_language() == 'eu') {
$spanish_page_id = pll_get_post($page_id, 'es');
$page_id = $spanish_page_id ?: $page_id;
}
}
$botones = [];
for ($i = 1; $i <= 4; $i++) {
$imagen = get_field('imagen_boton_' . $i, $page_id);
$enlace = get_field('enlace_boton_' . $i, $page_id);
$botones[] = [
'imagen' => $imagen,
'enlace' => $enlace,
];
}
return $botones;
}
public function getLastPostOpinion() {
return Timber::get_posts([
'post_type' => 'opinion',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
public function getLastPostCampana() {
return Timber::get_posts([
'post_type' => 'post',
'category_name' => 'campana',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
public function getLastPostConflicts() {
return Timber::get_posts([
'post_type' => 'post',
'category_name' => 'conflictos laborales',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
/**
* Funciones globales
*/
// Excluir páginas de la búsqueda
public function exclude_pages_from_search($query) {
if (!is_admin() && $query->is_main_query() && $query->is_search()) {
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'exclude_from_search',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'exclude_from_search',
'value' => '1',
'compare' => '!='
)
));
}
}
// genera embed para videos
public function generar_embed_universal($url) {
if (empty($url)) {
return false;
}
// YouTube
if (strpos($url, 'youtube.com') !== false || strpos($url, 'youtu.be') !== false) {
//error_log('es un vídeo de youtube'); // Debug
preg_match('/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/', $url, $matches);
if (!empty($matches[1])) {
$embed_data = [
'platform' => 'youtube',
'embed_url' => 'https://www.youtube.com/embed/' . $matches[1] . '?rel=0&modestbranding=1',
'thumbnail_url' => 'https://img.youtube.com/vi/' . $matches[1]. '/hqdefault.jpg',
'allow' => 'autoplay; encrypted-media; picture-in-picture'
];
//error_log('Embed URL generada: ' . $embed_data['embed_url']);
return $embed_data;
} else {
error_log('No se pudo extraer ID de YouTube');
}
}
// Vimeo
if (strpos($url, 'vimeo.com') !== false) {
preg_match('/vimeo\.com\/(\d+)/', $url, $matches);
if (!empty($matches[1])) {
return [
'platform' => 'vimeo',
'embed_url' => 'https://player.vimeo.com/video/' . $matches[1] . '?title=0&byline=0&portrait=0',
'allow' => 'autoplay; fullscreen; picture-in-picture'
];
}
}
// Si no se reconoce la plataforma
return [
'platform' => 'generic',
'embed_url' => $url,
'allow' => 'fullscreen'
];
}
// Hacer función disponible en Twig
public function add_videos_embed_to_twig ($twig) {
//error_log('Añadiendo función generar_embed a Twig'); // Debug
$twig->addFunction(new \Twig\TwigFunction('generar_embed', [$this, 'generar_embed_universal']));
return $twig;
}
}

View File

@ -171,7 +171,7 @@ button[type="reset"] {
.page-portada .opinion-article .card-img-overlay {
top: auto !important; /* Anula el top: 0 por defecto de Bootstrap */
bottom: 0;
height: 30%;
height: auto;
background: rgba(128, 128, 128, 0.8);
display: flex;
align-items: center;

21
template-portada.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/* Template Name: Plantilla de Portada */
use Timber\Timber;
$templates = [ 'templates/page-portada.twig' ];
$context = Timber::context(
[
'last_posts_opinion' => $site->getLastPostOpinion(),
'posts_campana' => $site->getLastPostCampana(),
'posts_conflicts' => $site->getLastPostConflicts(),
'lasts_posts_news' => $site->getLastsPostsNews(),
'botones_imagen' => $site->getBotonesEnlaces(),
]
);
//var_dump($context);
error_log('✅ Template-portada');
Timber::render( $templates, $context );

View File

@ -119,13 +119,17 @@
<h1 class="mb-4 position-relative fs-4 fw-bold sp-module-title">{{ __('Opinión', 'Sindikatua')|upper}}</h1>
<div class="flex-grow-1 d-flex">
{% if posts_opinion and posts_opinion|length > 0 %}
{% for article in posts_opinion %}
{% if last_posts_opinion and last_posts_opinion|length > 0 %}
{% for article in last_posts_opinion %}
{% set imagen = article.thumbnail.src('medium') | default('/wp-content/uploads/2025/10/Imagen_por_defecto_300.jpg') %}
{% set alt = article.thumbnail.alt | default('Imagen por defecto') %}
<div class="card w-100 h-100 secondary-article">
<a class="h-100" href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
class="card-img h-100 object-fit-cover"/>
<img src="{{ imagen }}"
alt="{{ alt }}"
class="card-img h-100 object-fit-cover"
style="aspect-ratio: 16/9;"/>
<div class="card-img-overlay d-flex flex-column justify-content-end align-items-start">
<div>
@ -143,6 +147,7 @@
</div>
</a>
</div>
{% endfor %}
{% else %}
<p>{{ __('No hay artículos', 'Sindikatua') }}</p>

View File

@ -7,7 +7,7 @@
{% if posts_noticias %}
{% for noticias in posts_noticias %}
{% set imagen = noticias.thumbnail.src | default('/wp-content/uploads/2025/10/Imagen_por_defecto.png') %}
{% set imagen = noticias.thumbnail.src | default('/wp-content/uploads/2025/10/Imagen_por_defecto_300.jpg') %}
{% set alt = noticias.thumbnail.alt | default('Imagen por defecto') %}
<div class="card my-3 position-relative">

View File

@ -10,7 +10,7 @@
{% for noticias in posts_opinion %}
{% set imagen = noticias.thumbnail.src | default('/wp-content/uploads/2025/10/Imagen_por_defecto.png') %}
{% set imagen = noticias.thumbnail.src | default('/wp-content/uploads/2025/10/Imagen_por_defecto_300.jpg') %}
{% set alt = noticias.thumbnail.alt | default('Imagen por defecto') %}
<div class="card my-3 position-relative">
@ -20,7 +20,7 @@
<img src="{{ imagen }}"
class="rounded-start object-fit-cover w-100 h-100 img-noticias"
alt="{{ alt }}"
style="min-height: 200px;"
style="min-height: 200px; max-height: 300px;"
/>
</a>
</div>

View File

@ -3,73 +3,73 @@
<div class="page-portada">
{# Sección noticias #}
{% if posts_noticias %}
{% if lasts_posts_news %}
<section class="recent-posts">
<div class="row g-4 mt-3">
{# Columna izquierda - Artículo principal #}
<div class="col-md-8">
{% set main_article = posts_noticias.posts[0] %}
<div class="card main-article">
<a href="{{ main_article.link }}">
<img src="{{ main_article.thumbnail.src('medium') }}"
alt="{{ main_article.thumbnail.alt }}"
class="card-img img-noticias" />
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ main_article.link }}">{{ main_article.title }}</a>
</h3>
</div>
</div>
</div>
{# Columna derecha - Dos artículos secundarios #}
<div class="col-md-4">
<div class="d-flex flex-column h-100 justify-content-between">
{% for article in posts_noticias.posts[1:2] %}
<div class="card secondary-article {% if loop.first %}media-mb{% endif %}">
<a href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
class="card-img img-noticias"/>
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ article.link }}">{{ article.title }}</a>
</h3>
</div>
</div>
{% endfor %}
<section class="recent-posts">
<div class="row g-4 mt-3">
{# Columna izquierda - Artículo principal #}
<div class="col-md-8">
{% set main_article = lasts_posts_news[0] %}
<div class="card main-article">
<a href="{{ main_article.link }}">
<img src="{{ main_article.thumbnail.src('medium') }}"
alt="{{ main_article.thumbnail.alt }}"
class="card-img img-noticias" />
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ main_article.link }}">{{ main_article.title }}</a>
</h3>
</div>
</div>
</div>
</section>
{# Columna derecha - Dos artículos secundarios #}
<div class="col-md-4">
<div class="d-flex flex-column h-100 justify-content-between">
{% for article in lasts_posts_news[1:2] %}
<div class="card secondary-article {% if loop.first %}media-mb{% endif %}">
<a href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
class="card-img img-noticias"/>
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ article.link }}">{{ article.title }}</a>
</h3>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</section>
{% else %}
no llega nada
<p>{{ __('No hay artículos', 'Sindikatua') }}</p>
{% endif %}
{# Sección vídeos + Opinión #}
<section class="py-4 margin-50">
{% include 'partials/section-videos.twig' %}
{% include 'partials/section-videos&opinion.twig' %}
</section>
{# Sección Enlaces #}
<section class="custom-buttons-section margin-50">
<h1 class="mb-4 position-relative fs-4 fw-bold sp-module-title">{{ __('Enlaces', 'Sindikatua')|upper }}</h1>
<section class="custom-buttons-section margin-50">
<h1 class="mb-4 position-relative fs-4 fw-bold sp-module-title">{{ __('Enlaces', 'Sindikatua')|upper }}</h1>
<div class="row g-3">
{% if botones_imagen %}
{% for boton in botones_imagen %}
<div class="col-6 col-sm-6 col-md-3 btn-hover">
<a href="{{ boton.enlace }}" class="btn-image-only d-block" target="_blank" rel="noopener noreferrer">
<img src="{{ boton.imagen.sizes.medium }}"
alt="{{ boton.imagen.alt }}"
class="img-fluid rounded">
</a>
</div>
{% endfor %}
{% endif %}
</div>
</section>
<div class="row g-3">
{% if botones_imagen %}
{% for boton in botones_imagen %}
<div class="col-6 col-sm-6 col-md-3 btn-hover">
<a href="{{ boton.enlace }}" class="btn-image-only d-block" target="_blank" rel="noopener noreferrer">
<img src="{{ boton.imagen.sizes.medium }}"
alt="{{ boton.imagen.alt }}"
class="img-fluid rounded">
</a>
</div>
{% endfor %}
{% endif %}
</div>
</section>
{# Sección Campañas / conflictos #}
<section class="recent-posts py-4">