diff --git a/page.php b/page.php index 595228a..8e9bb63 100644 --- a/page.php +++ b/page.php @@ -8,11 +8,6 @@ * different template. */ -/**namespace App; -use Timber\Timber; -$context = Timber::context(); -Timber::render( 'templates/page.twig', $context );*/ - $context = Timber::context(); $timber_post = Timber::get_post(); $context['post'] = $timber_post; @@ -21,14 +16,7 @@ $context['search_query'] = get_search_query(); //Timber::render( array( 'templates/page-' . $timber_post->slug . '.twig', 'page.twig' ), $context ); $parent = $timber_post->parent; -// Verificar si es una subpágina de servicios -$cast_subpagina_servicios = ($parent && ($parent->slug === 'servicios-privados' || $parent->slug === 'servicios-publicos')); -$eusk_subpagina_zerbitzu = ($parent && ($parent->slug === 'zerbitzu-pribatuak' || $parent->slug === 'zerbitzu-publikoak')); -$subpagina_industria = ($parent && ($parent->slug === 'industria')); - $slug_actual = $timber_post->slug; - -//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'); if ($parent && ($parent->slug === 'contactos' || $parent->slug === 'kontaktua') ) { @@ -37,12 +25,6 @@ if ($parent && ($parent->slug === 'contactos' || $parent->slug === 'kontaktua') } elseif ($pagina_servicios) { 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 "single-servicios": ' . $parent->slug); - Timber::render('templates/single-servicios.twig', $context); -} elseif ( $subpagina_industria ) { - //error_log('✅ (page.php) Página "Industria": ' . $parent->slug); - Timber::render('templates/single-industria.twig', $context); } elseif ( $slug_actual === 'noticias' || $slug_actual === 'berriak') { error_log('🔴 (page.php) Página noticias - ERROR'); } elseif ($parent && ($parent->slug == 'acerca-de-la-cnt' || $parent->slug == 'cnt-ri-buruz') ) { @@ -51,6 +33,6 @@ if ($parent && ($parent->slug === 'contactos' || $parent->slug === 'kontaktua') $context['post'] = $timber_post->parent; Timber::render(array('templates/page-acerca-de-la-cnt.twig'), $context); } else { - // error_log('✅ (page.php) Página General: ' . $timber_post->slug); + error_log('✅ (page.php) Página General: ' . $timber_post->slug); Timber::render(array('templates/page-' . $timber_post->slug . '.twig', 'templates/page.twig'), $context); } \ No newline at end of file diff --git a/src/StarterSite.php b/src/StarterSite.php index d477328..5c695da 100644 --- a/src/StarterSite.php +++ b/src/StarterSite.php @@ -290,7 +290,7 @@ class StarterSite extends Site { } } - // Si no hay videos en euskera, el botón euskera no detecta videos en ese idioma y te lleva a la home. + // Si no hay videos en euskera, el botón euskera no detecta documnentos en ese idioma y te lleva a la home. if (is_post_type_archive('documento')) { error_log('archive documentos'); foreach ($polylang_data['languages'] as $slug => &$lang) { @@ -405,99 +405,13 @@ class StarterSite extends Site { return $grupos; } - //Which paths is for 'servicios' - public function whichPathIs() { - $current_post = get_post(); - $slug_actual = $current_post->post_name; - - // Determinar qué página padre buscar según el slug actual - if ($slug_actual === 'servicios-publicos') { - $path = 'accion-sindical/servicios-publicos'; - $tipo = 'publicos'; - } elseif ($slug_actual === 'servicios-privados') { - $path = 'accion-sindical/servicios-privados'; - $tipo = 'privados'; - } elseif ($slug_actual === 'zerbitzu-publikoak') { - $path = 'ekintza-sindikala/zerbitzu-publikoak'; - $tipo = 'publikoak'; - } elseif ($slug_actual === 'zerbitzu-pribatuak') { - $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 - ]; - } - - $full_path = $pathInfo['path']; - $pag_servicios = get_page_by_path($full_path); - - if (!$pag_servicios) { - error_log("🔴 Página '$pathTipo.$path' no encontrada."); - return [ - 'subpaginas' => [], - 'pagination_Servicios' => null - ]; - } - - $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Obtener el número de página actual - $posts_per_page = 6; - - global $wp_query; // Guardar la query global actual - $temp_query = $wp_query; - - $wp_query = new \WP_Query([ // Crear nueva WP_Query - 'post_type' => 'page', - 'post_status' => 'publish', - 'post_parent' => $pag_servicios->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC', - 'posts_per_page' => $posts_per_page, - 'paged' => $paged, - ]); - - $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 = $pathInfo['tipo']; - } - - $pagination = new \Timber\Pagination($wp_query->max_num_pages); // Crear objeto de paginación - $wp_query = $temp_query; // Restaurar query original - - return $subpaginas; - - } - public function getContactoFields() { $post = Timber::get_post(); if (!$post) { return []; } - $form_shortcode = get_field('etiqueta_formulario', $post->ID); // o el campo ACF donde esté el shortcode + $form_shortcode = get_field('etiqueta_formulario', $post->ID); //error_log('✅ ID Página "Contactos": ' . $post->ID); $contactsFields = [ @@ -512,35 +426,6 @@ class StarterSite extends Site { ]; return $contactsFields; - - } - - private function getPostIndustry() { - - $pag_industry = get_page_by_path('accion-sindical/industria'); - - if (!$pag_industry) { - error_log('🔴 Página "Industria" no encontrada.'); - return []; - } else { - //error_log('✅ Página "Industria" encontrada.'); - } - - $subpaginas = Timber::get_posts([ - 'post_type' => 'page', - 'post_status' => 'publish', - 'post_parent' => $pag_industry->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC', - 'posts_per_page' => -1, - ]); - - foreach ($subpaginas as $pagina) { - //$pagina->imagen = $pagina->thumbnail ? $pagina->thumbnail->src('medium') : null; - $pagina->thumbnail= get_the_post_thumbnail_url($pagina->ID); - } - - return $subpaginas; } private function getListContacts() { @@ -581,11 +466,6 @@ class StarterSite extends Site { //Otras páginas $context['enlaces'] = $this->getEnlaces(); $context['contacto_info'] = $this->getContactoFields(); - $context['posts_industry'] = $this->getPostIndustry(); - // $context['subpaginas_servicios'] = \Timber\Helper::transient('subpaginas_servicios2', function () { - // return $this->getSubpaginasServicios(); - // }, 3600); - $context['subpaginas_servicios'] = $this->getSubpaginasServicios(); //Para Footer $context['lasts_posts_news'] = $this->getLastsPostsNews(); diff --git a/views/partials/head.twig b/views/partials/head.twig index b07377f..3efaa82 100644 --- a/views/partials/head.twig +++ b/views/partials/head.twig @@ -5,6 +5,7 @@ + {% do action('get_header') %} {{ function('wp_head') }} diff --git a/views/templates/page-acerca-de-la-cnt.twig b/views/templates/page-acerca-de-la-cnt.twig index 98c1cf7..e6e422f 100644 --- a/views/templates/page-acerca-de-la-cnt.twig +++ b/views/templates/page-acerca-de-la-cnt.twig @@ -14,7 +14,6 @@ {% endmacro %} {% block content %} -

{{ post.title }}

{# {{ dump(post.children) }} #} diff --git a/views/templates/page-industria.twig b/views/templates/page-industria.twig index b3941a2..6c7c723 100644 --- a/views/templates/page-industria.twig +++ b/views/templates/page-industria.twig @@ -3,12 +3,13 @@ {% block content %}

{{ post.title }}

-
- {% if posts_industry |length > 0 %} - {% for noticias in posts_industry %} - {% set imagen = noticias.thumbnail.src | default(imagen_default) %} - {% set alt = noticias.thumbnail.alt | default('Imagen por defecto') %} +
+ {% if post.children('page') |length > 0 %} + {% for subpagIndustria in post.children('page') %} + + {% set imagen = subpagIndustria.thumbnail.src | default(imagen_default) %} + {% set alt = subpagIndustria.thumbnail.alt | default('Imagen por defecto') %}
@@ -19,8 +20,8 @@
-
{{ noticias.title }}
-

{{noticias.content}}

+
{{ subpagIndustria.title }}
+

{{subpagIndustria.content}}

@@ -31,12 +32,12 @@

{{ __('No hay artículos', 'Sindikatua') }}

{% endif %} - - {% if pagination %} + + {# {% if pagination %}
{% include 'partials/pagination-custom.twig' %}
- {% endif %} + {% endif %} #}
diff --git a/views/templates/page-servicios.twig b/views/templates/page-servicios.twig index e0363ad..ac91e95 100644 --- a/views/templates/page-servicios.twig +++ b/views/templates/page-servicios.twig @@ -3,17 +3,12 @@ {% block content %}

{{ post.title }}

- - {# {% for pagina in post.children('page') %} - {{ pagina.title }} - {% endfor %} #} -
- {% if subpaginas_servicios |length > 0 %} - {% for noticias in subpaginas_servicios %} + {% if post.children('page') |length > 0 %} + {% for SubpagServicio in post.children('page') %} - {% set imagen = noticias.thumbnail.src | default(imagen_default) %} - {% set alt = noticias.thumbnail.alt | default('Imagen por defecto') %} + {% set imagen = SubpagServicio.thumbnail.src | default(imagen_default) %} + {% set alt = SubpagServicio.thumbnail.alt | default('Imagen por defecto') %}
@@ -24,8 +19,8 @@
-
{{ noticias.title }}
-

{{noticias.content}}

+
{{ SubpagServicio.title }}
+

{{SubpagServicio.content}}

@@ -36,13 +31,13 @@

{{ __('No hay artículos', 'Sindikatua') }}

{% endif %} - - {% set pagination = subpaginas_servicios.pagination %} + + {# {% set pagination = post.children.pagination %} {% if pagination %}
{% include 'partials/pagination-custom.twig' %}
- {% endif %} + {% endif %} #}
{% endblock %} \ No newline at end of file