3

I am currently struggling with the DXA Configuration / Resource settings. I was looking at the documentation Managing configuration (Java) and saw that I can either use my own Schema or the existing generic Schema based on key/value pairs. I personally dont want our editors to be able to mess the key/value pairs up so I decided to go the custom Schema way.

I do currently have an existing Schema that I want to use as DXA settings:

Schema Name: System - MVP Intranet Configuration

<intraConfiguration xmlns="uuid:00c95b0d-7dca-4fbf-9718-08a0c9b4ea47">
    <logo xlink:type="simple" xlink:href="tcm:1187-369286" xlink:title="Logo SVG" xmlns:xlink="http://www.w3.org/1999/xlink"></logo>
    <bgImage xlink:type="simple" xlink:href="tcm:1187-369173" xlink:title="page-background mountains" xmlns:xlink="http://www.w3.org/1999/xlink"></bgImage>
    <bgColor>#9fbcd7</bgColor>
    <siteUnit>Global Intranet</siteUnit>
    <siteHeading>Local Dev</siteHeading>
    <siteSubHeading>Local Intranet</siteSubHeading>
    <shareTicker>http://charts3.equitystory.com/teaser/...</shareTicker>
    <copyright>© Our Intranet 2017</copyright>
    <shareSubject>Link recommendation for our Intranet</shareSubject>
    <intranetNavigatorLabel>Intranet Navigator</intranetNavigatorLabel>
    <intranetNavigatorHeading>Select an Intranet Homepage</intranetNavigatorHeading>
    <hotNewsCategory xlink:href="tcm:1187-370836-1024" xlink:title="Top News" xmlns:xlink="http://www.w3.org/1999/xlink">Top News</hotNewsCategory>
    <globalNewsCategory xlink:href="tcm:1187-370835-1024" xlink:title="News" xmlns:xlink="http://www.w3.org/1999/xlink">News</globalNewsCategory>
</intraConfiguration>

So since the documentation only covers the Generic key/value Schema, my question is: How can I use my own configuration Schema as stated in the documentation?

I tried messing around with ${localization.getConfiguration('mvp-core.siteSubHeading')} (my DXA module is called MVP-Core) but I was only able to read values from the generic Schema, not from my own.

The settings Component is linked to my Module Configuration Component and is Published in the /_System/settings.json Page.

This is a picture of my Module configuration:

enter image description here

Thanks for your help and advice!

2 Answers 2

5

Whether you use a key value pair or a specific Schema doesn't matter, the configuration is serialized the exact same way. You can for example take a look at the Google Analytics module, it has a Configuration Schema not based on the key value pair and nothing specificly is done for that.

One catch however is that configuration is about string values, since they go into the module configuration JSON. So I'm not sure how the links in your configuration component will be dealt with. Furthermore, you mention you published the changes, if so, you can confirm they are available to the web application if you can find your configuration values in the modulename.json file in the binary storage (if not, then you probably forgot to call /admin/refresh to have the webapp clear its config cache.

Last remark, which is not an issue but more a suggestion; You seem to be mixing the configuration values and resource values in a single Component. I would suggest to separate those two, since texts like labels you might want translate, while configuration values like a background color you don't (so having them in separate Components makes the translation process easier).

1
  • Thanks Bart this was the exact problem. I have disabled the ehcache functionality with -Dnet.sf.ehcache.disabled=true so i assumed the configuration isnt cached as well. After clearign the cache, the actual new configuration appeared in my mvp-core.json
    – S. Gabriel
    Commented Jul 14, 2017 at 11:31
2

Follow up: Thanks Bart for answering my question, appreciate the help.

After restarting the web application and clearing the caches, my mvp-core.json was refreshed and looked like the following:

{
  "logo": "Logo SVG",
  "bgImage": "page-background mountains",
  "bgColor": "#9fbcd7",
  "siteUnit": "Global Intranet",
  "siteHeading": "Local Dev",
  "siteSubHeading": "Local Intranet",
  "shareTicker": "http://charts3.equitystory.com/teaser/...",
  "copyright": "© Our Intranet 2017",
  "shareLabel": "",
  "shareSubject": "Link recommendation for our Intranet",
  "intranetNavigatorLabel": "Intranet Navigator",
  "intranetNavigatorHeading": "Select an Intranet Homepage",
  "globalHomeHotNewsLimit": "",
  "localHomeHotNewsLimit": "",
  "hotNewsCategory": "Top News",
  "globalNewsCategory": "News"
}

I am now able to read the values from this configuration file with ${localization.getConfiguration('mvp-core.siteSubHeading')}

Note that neither the Multimedia Links nor the component links are correctly written into configuration json. Since this configuration file was a legacy one from my migration, i am going to change the concepts behind this anyways (like moving the header logo into header include Page) but keep this in mind for your own implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.