Files
cnt-sindikatua/page.php
2025-10-15 11:23:50 +00:00

56 lines
2.6 KiB
PHP

<?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.
*/
/**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;
$context['search_query'] = get_search_query();
//Timber::render( array( 'templates/page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
$parent = get_post($timber_post->post_parent);
// Verificar si es una subpágina de servicios
$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'));
$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');
if ($parent && ($parent->post_name === 'contactos' || $parent->post_name === 'kontaktua') ) {
// subpáginas de contactos
Timber::render('templates/page-contactos.twig', $context);
} 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->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 - ERROR');
// 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);
}