5

My understanding is that the fields structure in routes data should be fairly flat, having just the fields and then a value beneath.

Example:

---
name: about
placeholders:
  appname-main:
  - componentName: Heading
    fields:
      titleField:
        value: Page Title
      imageField:
        value:
          src: "/assets/img/logo.png"
          alt: Logo

I would like to instead provide a "deeper" set of data to a placeholder component. For example, I'd like to provide a image carousel component with an array of objects, each object containing image source, slide title, tags, etc.

Something like this:

---
name: about
placeholders:
  appname-main:
  - componentName: Carousel
    fields:
      data:
      - title:
          value: Image One
        img:
          value:
            src: "/assets/img/img1.png"
            alt: image one
        tags:
          value: tag1, tag2
      - title:
          value: Image Two
        img:
          value:
            src: "/assets/img/img2.png"
            alt: image two
        tags:
          value: tag2, tag3

Is this type of deeper data structure allowed? If so, how would the associated sitecore definitions file be structured?

Also, is this even a reasonable way to set things up? I am a front-end dev -- not a Sitecore dev -- so am unsure if this is how data would be setup within Sitecore.

Thanks in advance for your help.

1 Answer 1

3

Array fields cannot be defined directly on an item, but the Content List field type can hold an array of references to other content items - each with their own set of fields.

Here's an example of defining a content list field's data, and the field definition for the content list field.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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