Se ha producido un error al procesar la plantilla.
The following has evaluated to null or missing:
==> mlxPhoneUtilService [in template "20101#20128#SEARCH-BAR-V3-STR-DEFAULT-TEMPLATE" at line 4, column 21]
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign telValue = mlxPhoneUtilServic... [in template "20101#20128#SEARCH-BAR-V3-STR-DEFAULT-TEMPLATE" at line 4, column 1]
----
1<#assign cdn = (mlxUrlUtilService.getCdn(scopeGroupId))!"" />
2<#assign countryCode = (mlxExpandoService.getExpandoValueForClass("com.liferay.portal.kernel.model.Group","country-code", scopeGroupId).getString())!"" />
3
4<#assign telValue = mlxPhoneUtilService.getTelephone(mlxServiceContext)!"" />
5<#assign telDash = telValue?replace(" - ", " ")?replace(" ", "-")?replace("(", "")?replace(")", "") />
6<#assign telAlt = languageUtil.get(locale, "mlx.theme.menu.telephone") />
7<#assign openingHours = (mlxExpandoService.getExpandoValueForClass("com.liferay.portal.kernel.model.Group","opening-hours", scopeGroupId).getString())!"" />
8
9
10<#assign styleCss = "opacity: 0; pointer-events: none;" />
11
12
13<div class="corporate--header-contact">
14 <a href="tel:${telDash}" rel="nofollow" class="corporate--header-contact--button phone" id="working-time-phone" style="${styleCss}">
15 ${corporate.img(cdn + '/o/corporate-theme/theme-images/00_menu_ico_phone_orange.svg', false, 'class="corporate--header-contact--button-image"')}
16 <span>${telValue}</span>
17 </a>
18
19 <#assign contactMasterId=46017 />
20 <#assign contactLayout=(mlxMastersHelperService.getLayoutByMasterAndGroup(contactMasterId,scopeGroupId)!"") />
21 <#assign contactLabel = languageUtil.get(locale, "mlx.theme.menu.contact") />
22 <#assign contactLogo = themeDisplay.getPathThemeImages() + "/icons/00_menu_ico_mail_white.svg" />
23 <#if contactLayout?has_content>
24 <#assign contactUrl = contactLayout.getFriendlyURL() />
25 <a href="${contactUrl}?cta_origin=CTA_header" class="corporate--header-contact--button mail" title="${contactLabel}" data-gtm-event="click" data-gtm-event-label="/Contact" data-gtm-event-click-category="[currentPage]_Header_Contact">
26 ${corporate.img(cdn + '/o/corporate-theme/theme-images/00_menu_ico_mail_white.svg', false, 'alt="${contactLabel}"', 'title="${contactLabel}"', 'class="corporate--header-contact--button-image"')}
27 <span>${contactLabel}</span>
28 </a>
29 </#if>
30</div>
31
32<script>
33document.addEventListener("DOMContentLoaded", async () => {
34 try {
35 const workingTimeElement = document.getElementById('working-time-phone');
36 if (!workingTimeElement) return;
37
38 // 🔹 Llamada segura a una API interna autenticada
39 const response = await fetch(
40 '/o/corporate-rest-publics-services/v1.0/telephone',
41 {
42 method: 'GET',
43 headers: {
44 'Accept': 'application/json',
45 'x-csrf-token': Liferay.authToken // 👈 Token necesario para evitar 403 Forbidden
46 },
47 credentials: 'include' // 👈 Envia las cookies de sesión del usuario
48 }
49 );
50
51 if (!response.ok) {
52 console.error('Error al llamar a la API:', response.status, response.statusText);
53 return;
54 }
55
56 const obj = await response.json();
57
58 if (obj && obj.telephone) {
59 const tel = obj.telephone;
60 workingTimeElement.setAttribute('href', 'tel:' + tel.replace(/[^\d+]+/g, ''));
61 workingTimeElement.querySelector('span').textContent = tel;
62 }
63
64 // Fade-in effect
65 workingTimeElement.style.transition = 'all 0.4s ease-out';
66 workingTimeElement.style.opacity = '1';
67 workingTimeElement.style.pointerEvents = 'auto';
68 } catch (error) {
69 console.error('Error al obtener el teléfono:', error);
70 }
71});
72</script>