0

I'm using Sitecore 10 and SXA. And I'm trying to add template-id to be returned in JSON Result Layout.

I tried creating a new JSON Field under the rendering variant with field name value ('template' or 'templateid' or '_template') but with no luck it returns empty string. enter image description here

Also, I tried using JSON Template for example adding value '$item.Name' in the template field, but also with no luck it wasn't added to the Json field.

enter image description here

Could anyone help on how to add template id in JSON Result variant?

0

Out of the box it is not possible to render the Template in the JSON Results variant as the implementation only works with current item's fields and standard fields which are inherited from /sitecore/Templates/System/Templates/Standard Template.

In order to have the Template added to json you would need to implement your own extension method, similar to RenderJsonVariantList method in Sitecore.XA.Foundation.JsonVariants.Extensions.JsonVariantsExtensions. The next step would be to copy the JSON Results rendering and provide your own implementation.

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.