no hay thumbnail
+ {% endif %} +{{ pagina.title }}
+{{ pagina.content }}
+diff --git a/src/StarterSite.php b/src/StarterSite.php index 4d7206c..c20079a 100644 --- a/src/StarterSite.php +++ b/src/StarterSite.php @@ -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; } diff --git a/style.css b/style.css index 133873d..679094b 100644 --- a/style.css +++ b/style.css @@ -3,6 +3,12 @@ * Description: Tema Timber de nexos * Author: nexos estudios */ + +:root { + --rojo-cnt: #dc2d30; + --color-secundario: #6C757D; +} + @font-face { font-family: 'Yaro'; src: url('assets/fonts/yaro-font-family/YaroSt-Black.ttf') format('truetype'); @@ -99,7 +105,7 @@ } .recent-posts .card-title a:hover { - color: #E30B16; + color: var(--rojo-cnt); } .recent-posts .card.secondary-article .card-title { @@ -120,8 +126,9 @@ } /* PORTADA -> Titles */ -.page-portada .sp-module-title::after { - background: #cc1d1a; +.page-portada .sp-module-title::after, +.contacto-barakaldo .sp-module-title::after { + background: var(--rojo-cnt); content: ""; height: 1px; left: 0; @@ -130,8 +137,9 @@ width: 150px; } -.page-portada .sp-module-title::before { - background: #cc1d1a; +.page-portada .sp-module-title::before, +.contacto-barakaldo .sp-module-title::before { + background: var(--rojo-cnt); content: ""; height: 1px; left: 0; @@ -180,5 +188,24 @@ } .active-acerca { - background-color: #dc2d30; + background-color: var(--rojo-cnt); } + +.servicios-publicos .card img, +.servicios-privados .card img { + width: 100%; + max-width: 50%; + height: auto; +} + +.enlaces button:not(.collapsed) { + background-color: var(--rojo-cnt); + color: #fff; + border-color: none; +} + +.enlaces button:focus, +.enlaces button:active { + outline: none; + box-shadow: none; +} \ No newline at end of file diff --git a/views/templates/page-barakaldo.twig b/views/templates/page-barakaldo.twig index fc5cd0a..90ccd30 100644 --- a/views/templates/page-barakaldo.twig +++ b/views/templates/page-barakaldo.twig @@ -1,6 +1,49 @@ {% extends 'layouts/base.twig' %} {% block content %} -
+ + Barakaldo
+ {% endblock %} diff --git a/views/templates/page-documentos.twig b/views/templates/page-documentos.twig index d1daf5e..e580151 100644 --- a/views/templates/page-documentos.twig +++ b/views/templates/page-documentos.twig @@ -5,67 +5,66 @@ Dokumentuak / Documentos -{{ dump(documentos) }}#} +
{{ dump(documentos) }}#} - {% for doc in documentos %} -
{{ doc.content }}
- {% endif %} -{{ doc.content }}
+ {% endif %} ++ + Enlaces
+ + {% if enlaces %} +{{ dump(enlaces) }}#} + {% endblock %} diff --git a/views/templates/page-industria.twig b/views/templates/page-industria.twig index add5ab4..da17a67 100644 --- a/views/templates/page-industria.twig +++ b/views/templates/page-industria.twig @@ -1,6 +1,8 @@ {% extends 'layouts/base.twig' %} {% block content %} -
+ + Industria
{% endblock %} diff --git a/views/templates/page-servicios-privados.twig b/views/templates/page-servicios-privados.twig index 6353a11..04c1273 100644 --- a/views/templates/page-servicios-privados.twig +++ b/views/templates/page-servicios-privados.twig @@ -1,6 +1,36 @@ {% extends 'layouts/base.twig' %} {% block content %} -+ + Servicios Privados
+no hay thumbnail
+ {% endif %} +{{ pagina.content }}
+No hay subpáginas disponibles.
+ {% endfor %} ++ + Servicios Públicos
+ +no hay thumbnail
+ {% endif %} +{{ pagina.content }}
+No hay subpáginas disponibles.
+ {% endfor %} +