4

I want to access Structure Group metadata in my DXA 2.0 (Java) Pages. Following the documentation I have added the InheritMetadataPageModelBuilder model builder to the pipeline in my Page Rendering TBB. If I preview the page, or query the Model Service directly I see that Metadata from the Structure Group is indeed present in the published JSON in a Metadata element, along with the Page Metadata. However, I don't see how I can access this data in the (Java) Page Model.

In the map returned by DefaultPageModel.getMeta() I see only the Page Metadata and not that from the Structure Group. I don't see any other properties or methods which might help. How can I access the additional metadata added to the model by the InheritMetadataPageModelBuilder?

  • Take reference from here: github.com/sdl/dxa-web-application-java ? – Bhawna Jain Mar 20 '18 at 6:53
  • I can't see anywhere in the code where the metadata is processed in the DefaultModelBuilder... but maybe I am missing something – Will Price Mar 20 '18 at 9:26
  • did u try searching like this -->>github.com/sdl/dxa-web-application-java/… – Bhawna Jain Mar 20 '18 at 10:07
  • I debugged the application and checked all properties and methods on the DefaultPageModel – Will Price Mar 20 '18 at 10:52
  • If you already see it in the published JSON, I would expect that you should be able to map it explicitly in your defaultPageModel as property using DXA @SemanticPropety('field name') – Headoo Mar 23 '18 at 14:00
2
+25

You can create (and register) a custom Page Model class and use semantic mapping to map the metadata fields to properties of the View Model.

For semantic mapping to work, the metadata fields must be defined in the (semantic) Schema of the Page. So, you may have to add those fields to your Page’s Metadata Schema.

  • I had tried semantic mapping on a custom Page Model, but that didn't work. I guess because our pages do not have a metadata schema (metadata comes from a component on the page instead). I guess we are stuck then. – Will Price Mar 26 '18 at 8:33
  • I am able to get tag though metadata which i added on page model..but if i do same for structure group, i am getting that tag as only a string.:( – Bhawna Jain Dec 3 '18 at 5:55
2

I am using DXA 1.2 .Net version. In my Tridion page template, i have added the "Add inherited metadata to page" TBB (which is available under the DD4T folder.

DXA delivery side, i am able to access the structure group information from my page model. which means the default model builder able to process the structure information and store it in the page model.

I am not sure this is different in Java version.

  • As described above, I have done the same in my .NET DD4T application .(Not DXA) that TBB adds the structure group metadata values into the published JSON and I just created a property in my Page Model class for it. It may be different in the Java. – Headoo Mar 27 '18 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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