I need document path for identifying the channel (root channel content folder). Then, it will be used for gathering API url that will be used in Open UI for fetching data from API.
I’m not sure if there’s an API to retrieve the document path.
Perhaps you can add configuration in the frontend:config property of your OpenUI Extension configuration [2] to include the URL of your backend API.
You can read the config like the following:
// read the frontend:config string property and parse it to a json object.
const config = ui.extension.config;
// you may use the string value of the config directly or parse it to JSON if possible...
Thank you for quick reply.
Yes, I am using Open UI extension config for storing some common properties but it does not fit my needs for 100%.
By opening the document (where I have Open UI Extension), Open UI needs somehow identify document location (JCR Path) of the document and, based on this info, gather an API url (https:api/example.com/{channel}/products)
As the OpenUI API can give the document handle UUID, perhaps you can implement a repository managed JAX-RS component [3] giving the document info based on the uuid.
Thank you for advice. Yeah, it is a way how I can solve the problem.
One more option is to use derived property function for populating document path info to the document, then I can fetch this property in Open UI.
But it looks a little bit complicated for such case, from my point of view.
Another way is to customise OpenUiStringPlugin and FieldLookupService but I would not like to modify default platform functionality as it can lead to some problem during platform version upgrade and support.
If you configured a reverse proxy to enable the Channel Manager preview like [1], then your delivery application URL can be exposed to both: (1) delivery-tier url, and (2) preview-purpose authoring-tier URL with /site context path like the following:
So, in the above example, the delivery-tier domain (www.example.com) exposes the delivery application only, but the authoring-tier domain (cms.example.com) exposes both the authoring application (/cms) and the delivery application at /site context path, for preview purpose.
Therefore, if your “API” to use in your OpenUI Extension is always deployed onto the “delivery app” anyway, then your OpenUI Extension may possibly use the “API” url in the cms domain too without having to do anythings extra. e.g, https://cms.example.com/site/api/mystuffs.
Thanks for the feedback!
Not sure if it will help directly or not, but we will support variable references and interpolation using the Container Configuration in the coming release, v14.7+, in the near future.
In summary, since v14.7, the frontend:config property value may contain variable references using the Container Configuration [1] for the CMS application (e.g, $CATALINA_BASE/conf/platform.properties).
Suppose this property is set to the following containing a reference to the variable called “backend.url”:
{ "my.backend.api.url": "${backend.url}" }
And if you set the backend.url property with value, “https://api.example.com”, in the Container Configuration [1] for the CMS application (e.g, $CATALINA_BASE/conf/platform.properties), then the property value will be interpreted to the following at runtime: