1

I am using Sitecore 9.3 Instance with JSS.

I need to create a component that consists of 2 templates - say - Template1.sitecore.js and Template2.sitecore.js and 1 rendering - RenderingName/index.js.

So that, when I deploy it using jss deploy app command, only one json rendering is created in sitecore/Layouts/Renderings/ folder.

I am able to achieve it in Sitecore 9.2 by adding parameter - createRendering : false in Template2.sitecore.js, so that it does not create a component corresponding to that one. See code below -

import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-manifest';

export default function(manifest) {
  manifest.addComponent({
    name: 'Template2',
    icon: SitecoreIcon.DocumentTag,
    fields: [
    { name: 'title', type: CommonFieldTypes.SingleLineText,displayName:'Title' , section: 'Data' },
{ name: 'description', type: CommonFieldTypes.RichText,displayName:'Description' , section: 'Data' },
    ],
createRendering: false,

allowedPlaceholders: ['jss-main'],

  });
}

This worked for Sitecore 9.2 but when I use it in Sitecore 9.3, it creates a component for Template2.

Can anybody please suggest why it is not working in Sitecore 9.3 and how to resolve this?

1
  • Is there any issue if you create Template2 separately using manifest.addTemplate or this doesn't fit your requirement.? Commented May 5, 2020 at 13:32

1 Answer 1

1

If you just want to create an additional template Template2 then you may try the below,

Add below file "Template2.sitecore.js" under "\sitecore\definitions\templates".

import { CommonFieldTypes } from '@sitecore-jss/sitecore-jss-manifest'

export default function (manifest) {
  manifest.addTemplate({
    name: 'Template2',
    fields: [
      { name: 'title', type: CommonFieldTypes.SingleLineText,displayName:'Title' , section: 'Data' },
  { name: 'description', type: CommonFieldTypes.RichText,displayName:'Description' , section: 'Data' },
      ],
  })
}
1
  • Yup. This worked. Thanks!
    – NewbieHere
    Commented May 8, 2020 at 3:50

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.