Child Page Properties multified access
Hi All,
How can we access child page properties multifield.
In my project we have created multifield in the page properties and i wanted to access in the navigation component and display it.
Kr,
Sanjay
Hi All,
How can we access child page properties multifield.
In my project we have created multifield in the page properties and i wanted to access in the navigation component and display it.
Kr,
Sanjay
Hi @savi50 ,
I think you can extend navigation component and in this path (/libs/core/wcm/components/navigation/v1/navigation/itemContent.html) we can add custom model to get your customised multifield page properties. For eg. like below
<template data-sly-template.itemContent="${@ item='The navigation item'}">
<a href="${item.URL}" aria-current="${item.current && 'page'}"
data-cmp-clickable="${item.data ? true : false}"
class="cmp-navigation__item-link">${item.title}
</a>
<!-- /*extended code */ -->
<sly data-sly-use.additionalProperties="${'com.test.model.CustomNavigationModel' @ path=item.path}">
<p> ${additionalProperties.customProp} </p>
</sly>
<!-- /*extended code */ -->
</template>//Additional Sling model
@Model(adaptables = {SlingHttpServletRequest.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class CustomNavigationModel {
@RequestAttribute(name = "path")
private String path;
@SlingObject
private ResourceResolver resourceResolver;
String customProp;
@PostConstruct
protected void init() {
Resource resource = resourceResolver.resolve(path+ "/jcr:content");
ValueMap vm = resource.adaptTo(ValueMap.class);
String[] customProps = vm.get("sling:vanityPath", String[].class);
if(customProps!=null) {
customProp = Arrays.toString(customProps);
}
}
public String getCustomProp() {
return customProp;
}
}Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.