Files
cnt-sindikatua/page.php

56 lines
2.6 KiB
PHP
Raw Normal View History

2025-07-14 07:33:32 +00:00
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*/
2025-07-16 07:33:09 +00:00
/**namespace App;
2025-07-14 07:33:32 +00:00
use Timber\Timber;
2025-07-16 07:33:09 +00:00
$context = Timber::context();
Timber::render( 'templates/page.twig', $context );*/
2025-07-14 07:33:32 +00:00
$context = Timber::context();
2025-07-16 07:33:09 +00:00
$timber_post = Timber::get_post();
$context['post'] = $timber_post;
2025-08-13 08:58:35 +00:00
$context['search_query'] = get_search_query();
2025-08-07 12:05:32 +00:00
2025-07-24 09:31:42 +00:00
//Timber::render( array( 'templates/page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
2025-08-07 12:05:32 +00:00
$parent = get_post($timber_post->post_parent);
2025-10-03 08:09:11 +00:00
// Verificar si es una subpágina de servicios
2025-10-08 08:06:54 +00:00
$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'));
2025-10-14 15:08:21 +00:00
2025-10-09 10:32:56 +00:00
$slug_actual = $timber_post->post_name;
2025-10-08 10:38:06 +00:00
//error_log('✅ (page.php) Slug actual: ' . $slug_actual);
2025-10-08 08:06:54 +00:00
$pagina_servicios = ($slug_actual === 'servicios-privados' || $slug_actual === 'servicios-publicos' || $slug_actual === 'zerbitzu-pribatuak' || $slug_actual === 'zerbitzu-publikoak');
2025-10-03 08:09:11 +00:00
if ($parent && ($parent->post_name === 'contactos' || $parent->post_name === 'kontaktua') ) {
// subpáginas de contactos
2025-08-07 12:05:32 +00:00
Timber::render('templates/page-contactos.twig', $context);
2025-10-08 08:06:54 +00:00
} elseif ($pagina_servicios) {
2025-10-14 15:08:21 +00:00
error_log('✅ (page.php) Página Servicios: ' . $slug_actual);
2025-10-03 08:09:11 +00:00
Timber::render('templates/page-servicios.twig', $context);
2025-10-08 08:06:54 +00:00
} elseif ( $cast_subpagina_servicios || $eusk_subpagina_zerbitzu ) {
2025-10-14 15:08:21 +00:00
error_log('✅ (page.php) Página "single-servicios": ' . $parent->post_name);
2025-08-13 08:58:35 +00:00
Timber::render('templates/single-servicios.twig', $context);
2025-10-08 08:06:54 +00:00
} elseif ( $subpagina_industria ) {
2025-10-08 10:38:06 +00:00
//error_log('✅ (page.php) Página "Industria": ' . $parent->post_name);
2025-10-08 08:06:54 +00:00
Timber::render('templates/single-industria.twig', $context);
2025-10-14 15:08:21 +00:00
} elseif ( $slug_actual === 'noticias' || $slug_actual === 'berriak') {
2025-10-15 11:23:50 +00:00
// $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 - ERROR');
// Timber::render('templates/page-noticias.twig', $context);
2025-08-07 12:05:32 +00:00
} else {
2025-10-09 10:32:56 +00:00
error_log('✅ (page.php) Página: ' . $parent->post_name);
2025-08-07 12:05:32 +00:00
Timber::render(array('templates/page-' . $timber_post->post_name . '.twig'), $context);
}