2

I am using Sitecore 10 with Angular app JSS, I created shared component "Header" like that:

enter image description here

I have a rendering parameters background field, I need to add it in yml files of pages to be different in each page. However, when I added in home page like this:

enter image description here

I got this error. Please note, it was working when it was in header component not in the page.

enter image description here

Here is the header component definition:

enter image description here

Any ideas about how can I read it in pages?

2

We had similar requirement to distinguish whether page is secured or not. Based on that we are then checking whether user is authenticated or not.

Implementation is using React but I think for Angular it will be similar in your case.

We have added new field of type checkbox "securedRoute" to /sitecore/definitions/route.sitecore.js:

enter image description here

In the route definition / yml of pages, we are setting it to true where needed as you don't need to set it to false which is default value:

enter image description here

And then on layout we are checking whether it is true:

enter image description here

In your case, you will show/hide background...

0

In order for sitecore to recognize it you have to define it also in your component definition. You should edit the .js definition file located /sitecore/definitions/components/ and you will need to add the params array and mention the expected parameters:

addComponent(manifest, {
  name: "Hello-World",
  displayName: "Hello-World",
  fields: [{ name: "title", type: CommonFieldTypes.SingleLineText }],
  params: ["background"],
})
1
  • i did this already, and it is working when i added it in component yml, but in pages yml not working. i think this happen bz the shared component and trying to add the params in pages not in component datasource. – shimaa elsayed Mar 23 at 12: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.