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.

up vote 3 down vote accepted

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.

  • Perfect, thanks! – The Chad Jul 22 at 9:25

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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