Expand my Community achievements bar.

SOLVED

Context Aware Configurations:Context Path Strategies

Avatar

Community Advisor

Dear Members,

We are using XFs for header and footer, these Xfs are being authored with respective components. We wanted to use context aware configuration for some site specific data. To implement it we need to add "sling:configRef" property to the root of every locale for Pages as well as Xfs. Since site is already live with AEM as CS and we don't want to make any change for sling:configRef on content so planing to use io.wcm Context Path Strategies so do you think this will be helpful for this requirement if yes then how can I proceed with it for Xfs and pages.

Waiting for your suggestion.
Thank you

Umesh Thakur

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Umesh_Thakur 
You can add @sling:configRef to root of your site(/content/myite), no need to add to every local.

e.g. Content and conf strategy

/content/myite/de

/content/myite/fr

 

/conf/myite/de

/conf/myite/fr

 

If you want to reuse config within XF editor then@sling:configRef to root of your XF and modify contextPathRegex

contextPathRegex="^/content(/.+)?$|^/content/experience-fragments(/.+)?$"


Arun Patidar

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hi @Umesh_Thakur 
You can add @sling:configRef to root of your site(/content/myite), no need to add to every local.

e.g. Content and conf strategy

/content/myite/de

/content/myite/fr

 

/conf/myite/de

/conf/myite/fr

 

If you want to reuse config within XF editor then@sling:configRef to root of your XF and modify contextPathRegex

contextPathRegex="^/content(/.+)?$|^/content/experience-fragments(/.+)?$"


Arun Patidar

Avatar

Community Advisor

Thank you for the response @arunpatidar .

Will implement the same way.

Avatar

Community Advisor

Hi @arunpatidar ,

I was trying to implement the above suggestion as :

For XFs:

in root at "/content/experience-fragments/mysite-fragments" I added sling:configRef as "/conf/mysite/ca-configs/" my xfs are organised as :

"/content/experience-fragments/mysite-fragments/language-masters/en_us" and CA config is organised as "/conf/mysite/ca-configs/language-masters/en_us" and 

/apps/mysite/osgiconfig/config/io.wcm.caconfig.extensions.contextpath.impl.AbsoluteParentContextPathStrategy-site.cfg.json with below config:

{
"levels:int[]":[1,2,3,4,5,6,7],
"contextPathRegex":"^/content/experience-fragments/mysite-fragments(/.+)?$",
"configPathPatterns":[
"/conf/mysite/ca-configs/[^/]+"
],
"templatePathsBlacklist":[]
}

but still not picking the config when I open an xf at "/content/experience-fragments/mysite-fragments/language-masters/en_us/navigation/us-footer/master.html"
I can see the configuration in configMgr.
I was reffering your https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/ui.apps/src/main/content/jcr_root/apps/a... repo but here you have set sling:configRef at /content/aemlab and /content/aemlab/oneweb level as well so not sure how to proceed in my scenario.

Thanks

Umesh Thakur

 

Avatar

Community Advisor

Hi @Umesh_Thakur 
you don't needed sling:configRef at children level e.g./content/aemlab/oneweb I think, my code base included that because I changed the project structure and copy paste the root page, so you can ignore that,

here is the original changes looks like : https://github.com/arunpatidar02/aemaacs-aemlab/blob/bfdade198934da30e9160572bd7652e8b5d73c0c/ui.con... 

 

Is your pages picking up the context-aware-config, what about editor? can you see the config in the editor.

 



Arun Patidar