Expand my Community achievements bar.

SOLVED

Using SDI within AEM on a component with design mode settings

Avatar

Level 1

I have created a component that outputs a text label and an image.  There is also a design setting provided for the template to set something relevant to the presentation.  When used on a page, it works fine.

 

However if I use Sling Dynamic Includes to enhance the component to have SSI with a TTL on it, the component fails.  The Style object used to get the design settings is null.

 

@Injectpublic LogoModel(
@ScriptVariable @Named("currentPage") final Page currentPage,
@ScriptVariable @Named("currentStyle") final Style currentStyle) {

 

Is this a known limitation of using SDI?  Is there another way of loading design mode settings into the model?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@james-appleby ,

 

you can access policy nodes by using below code snippets 

 

import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import org.apache.sling.api.resource.ValueMap;

// placed within Sling Model or Java-Use API

ResourceResolver resourceResolver = resource.getResourceResolver();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
ContentPolicy contentPolicy = policyManager.getPolicy(resource);
ValueMap policyValues = contentPolicy.getProperties();

thanks,

aruna 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

@james-appleby ,

 

you can access policy nodes by using below code snippets 

 

import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import org.apache.sling.api.resource.ValueMap;

// placed within Sling Model or Java-Use API

ResourceResolver resourceResolver = resource.getResourceResolver();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
ContentPolicy contentPolicy = policyManager.getPolicy(resource);
ValueMap policyValues = contentPolicy.getProperties();

thanks,

aruna