ADD content & styles
This commit is contained in:
@@ -369,7 +369,7 @@ class StarterSite extends Site {
|
||||
'posts_per_page' => -1,
|
||||
]);
|
||||
|
||||
error_log('Número de posts encontrados: ' . count($posts));
|
||||
//error_log('✅ Número de posts "Documentos" encontrados: ' . count($posts));
|
||||
|
||||
$documentos = [];
|
||||
|
||||
@@ -398,6 +398,131 @@ class StarterSite extends Site {
|
||||
return $documentos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene los grupos de enlaces de la página "Enlaces"
|
||||
*/
|
||||
private function getEnlaces() {
|
||||
$grupos = [];
|
||||
|
||||
// Buscar página por su slug
|
||||
$page = get_page_by_path('enlaces');
|
||||
|
||||
if (!$page) {
|
||||
error_log('🔴 Página "enlaces" no encontrada con get_page_by_path().');
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!have_rows('grupos_enlaces', $page->ID)) {
|
||||
error_log('🔴 Array vacío');
|
||||
return [];
|
||||
} else {
|
||||
//error_log('✅ "grupos_enlaces" tiene filas.');
|
||||
}
|
||||
|
||||
// Si se encuentra la página y el campo tiene filas
|
||||
if ($page && have_rows('grupos_enlaces', $page->ID)) {
|
||||
|
||||
$field = get_field('grupos_enlaces', $page->ID);
|
||||
//error_log('📦 Contenido de get_field: ' . print_r($field, true));
|
||||
//error_log('✅ Página "enlaces" encontrada con ID: ' . $page->ID);
|
||||
|
||||
while (have_rows('grupos_enlaces', $page->ID)) {
|
||||
the_row();
|
||||
|
||||
$grupo = [
|
||||
'titulo' => get_sub_field('titulo_grupo'),
|
||||
'enlaces' => []
|
||||
];
|
||||
|
||||
// Recorrer enlaces dentro del grupo
|
||||
if (have_rows('enlaces')) {
|
||||
while (have_rows('enlaces')) {
|
||||
the_row();
|
||||
|
||||
$titulo_enlace = get_sub_field('titulo_enlace');
|
||||
$url_enlace = get_sub_field('url_enlace');
|
||||
|
||||
if (!empty($titulo_enlace) && !empty($url_enlace)) {
|
||||
$enlace = [
|
||||
'titulo' => $titulo_enlace,
|
||||
'url' => $url_enlace,
|
||||
'target' => get_sub_field('target_enlace') ?: '_self'
|
||||
];
|
||||
|
||||
$grupo['enlaces'][] = $enlace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Añadir grupo solo si tiene título y enlaces válidos
|
||||
if (!empty($grupo['titulo']) && !empty($grupo['enlaces'])) {
|
||||
$grupos[] = $grupo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $grupos;
|
||||
}
|
||||
|
||||
// Get subpages of "servicios publicos"
|
||||
private function getPaginasServiciosPublicos() {
|
||||
|
||||
$pag_servicios_publicos = get_page_by_path('accion-sindical/servicios-publicos');
|
||||
|
||||
if (!$pag_servicios_publicos) {
|
||||
error_log('🔴 Página "Servicios públicos" no encontrada.');
|
||||
return [];
|
||||
}
|
||||
|
||||
$subpaginas = Timber::get_posts([
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_parent' => $pag_servicios_publicos->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;
|
||||
}
|
||||
|
||||
// Get subpages of "servicios privados"
|
||||
private function getPaginasServiciosPrivados() {
|
||||
|
||||
$pag_servicios_privados = get_page_by_path('accion-sindical/servicios-privados');
|
||||
|
||||
if (!$pag_servicios_privados) {
|
||||
error_log('🔴 Página "Servicios privados" no encontrada.');
|
||||
return [];
|
||||
}
|
||||
|
||||
$subpaginas = Timber::get_posts([
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_parent' => $pag_servicios_privados->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 formContact() {
|
||||
$form_test = do_shortcode('[contact-form-7 id="5ed613c" title="Formulario de contacto 1"]');
|
||||
|
||||
return $form_test;
|
||||
}
|
||||
|
||||
//Global variables
|
||||
public function add_global_context($context) {
|
||||
@@ -413,6 +538,10 @@ class StarterSite extends Site {
|
||||
$context['posts_campana'] = $this->getCampanaArticles();
|
||||
$context['paginas_acerca'] = $this->getPaginasAcerca();
|
||||
$context['documentos'] = $this->getDocumentos();
|
||||
$context['enlaces'] = $this->getEnlaces();
|
||||
$context['subpaginas_servicios_publicos'] = $this->getPaginasServiciosPublicos();
|
||||
$context['subpaginas_servicios_privados'] = $this->getPaginasServiciosPrivados();
|
||||
$context['form_test'] = $this->formContact();;
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user