I would like to make a resources/labels schema which uses a custom configuration schema with embedded and multi-value embedded fields. Will the @Html.Resource("module.resourceidentifier")
be able to grab embedded fields?
2 Answers
As documented http://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v7/GUID-5DED64BE-E71B-4C64-8131-151D336AAA08
A resouce/label Component can use the General Configuration Schema, or you can create a custom Schema. The General Configuration Schema uses an Embedded Name Value Pair Schema, which validates that you can use Embedded Schemas.
However depending on what you exactly want (which you fail to describe in your question), it might or might not work.
In case you wanted to use an Embeddable Schema for grouping, might I suggest to simply use multiple resource/label Components, since you don't have to store all your resources/labels for a module in a single Component (so that we can keep it more manageble also during translation, and possibly even reuse the same resource/label Component for multiple modules.
-
Thanks Bart, I updated the question for clarification. It a custom schema with embedded and multi-value embedded fields. The documentation does not describe limitations to a custom resource schema, but it also does not describe how @Html.Resource() would address an embedded resrouce field or a multivalue embedded resource field.– Jan HCommented Jan 27, 2017 at 16:31
-
@JanH there is basically only support for key value pairs, so maybe you should update your question with some more details and a description of why you need this, because I'm not sure what exactly you want to use. Commented Jan 27, 2017 at 16:45
-
I have two use cases in a real life implementation. The first is separation of fields with an embedded schema, i.e we have single and plural date labels, separators etc. Those are all related but could be nicely grouped in embedded schemas for clarity. This is the grouping use case you mentioned in the answer. This could be split in multiple components which will also bloat the number of components. Over all schemas the reource key will have to be unique as well since the resource id for
Html.Resouce
takes the fieldname.– Jan HCommented Feb 6, 2017 at 18:15 -
The second use case is a language selector. The site localization in
WebRequestContext.Localization.SiteLocalizations
is not exensible, so I like to create an additional localization configuration which must hold a multivalue embedded field with fields additional site configuration. I solved this one by using a normal component instead of a resource component.– Jan HCommented Feb 6, 2017 at 18:15
Resource components do not support embedded fields or multi value embedded fields for custom schemas. Html.Resource("module.resourceidentifier")
will not retrieve embedded fields on a custom schema.
The key-value pair configuration schema uses a multi value embedded field, but all values from both key-value pair and from custom resource schemas are flattened into one list, published and retrieved in the website in the same way.
In fact the field name, or key, needs to be unique in the module: in Html.Resource("module.resourceidentifier")
the "module" is the lowercase module name and "resourceidentifier" is the cased field name or key.