LogoLogo
  • Introduction
  • Early Access
  • System Requirements
  • Elements FAQ
  • Purchasing FAQ
  • Licensing FAQ
    • License Types
  • Why Elements?
    • Static Website Benefits
    • Build a Digital Garden
  • Community Forum
  • Marketplace
  • Elements App
    • Getting Started
    • Keyboard Shortcuts
    • Design System
    • Editor
      • Apple Intelligence
      • Component Inspector
      • Dark Mode
      • Node Browser
      • Page Manager
      • Preview
      • Resources
      • Responsive Breakpoints
      • Workspaces
    • Components
      • Built-in Components
        • Accordion
        • Background
        • CMS
          • Twig Syntax
          • CMS Online Editor
        • Button
        • Container
        • Divider
        • Dropdown
        • Flex
        • Filter
        • Filter Tags
        • Form
        • Gallery
        • Grid
        • Image
        • Menu
        • Modal
        • Modal Close
        • Reveal
        • Image Slider
        • SVG
        • Text
        • Top Pages
        • Typography
        • Video
      • Common Controls
        • Link
        • Layout
        • Sizing
        • Spacing
        • Transitions
        • Effects
        • Filters
        • Transforms
        • Borders
        • Advanced
      • Custom Components
    • Templates
      • Global Templates
    • Site Settings
      • Template
      • Publishing
    • Theme Studio
      • Theme
      • Colors
      • Screens
      • Font Family
      • Font Size
      • Spacing
      • Shadows
      • Border Width
      • Border Radius
      • Typography
    • How to
      • Add an Icon Inside a Button
      • Adjust Smooth Scroll Speed
      • Apply Anchor Scroll Padding
      • Add Snow to your Website
      • Build a Sticky Menu
      • Center Align Components
      • Create a Card
      • Site Banner with Text
      • Make a two column layout
    • Resources
    • Troubleshooting
    • SEO
    • Robots.txt
    • Advanced
      • URL Scheme
  • Elements Language
    • Introduction
      • Getting Started
      • Component Styling
    • Element Pack
      • info.json
      • Components
        • info.json
        • Icons
        • Properties.json
          • Grouping Controls
          • Default Values
          • General Structure
            • Title
            • ID
            • Format
            • Visible
            • Enabled
            • Responsive
          • UI Controls
            • Divider
            • Heading
            • Image
            • Information
            • Link
            • Number
            • Resource
            • Segmented
            • Select
            • Slider
            • Switch
            • Text
            • Text Area
            • Theme Border Width
            • Theme Border Radius
            • Theme Color
            • Theme Font
            • Theme Spacing
            • Theme Shadow
            • Theme Text Style
            • Theme Typography
        • Templates
          • Portal
          • Backend
          • Conditional Statements
          • Regular Expressions
          • Looping
          • Includes
          • Image Resources
          • HTML
            • Anchor
            • Raw
            • Editable Content
            • Dropzones
            • Inline templates
          • CSS
          • JavaScript
        • Assets
        • Hooks.js
          • Common use cases
          • Passing data to templates
          • Working with Collections
          • Working with UI Controls
          • Working with Resources
          • Available Functions
            • rw.addAnchor
            • rw.getBreakpoints
            • rw.getBreakpointNames
            • rw.getResponsiveValues
            • rw.resizeResource
            • rw.setProps
            • rw.setRootElement
          • Available Data
            • rw.collections
            • rw.component
            • rw.node
            • rw.pages
            • rw.project
            • rw.props
      • Collections
        • Data collections in Hooks.js
        • Accessing Data in Templates
        • Collections in properties.json
      • Shared Files
        • Assets
        • Templates
      • Themes
    • Troubleshooting
  • Elements Cloud
    • Getting Started
    • Troubleshooting
  • Elements Store
    • Getting Started
    • Add-on Guidelines
  • Branding
    • Logotype
    • Logotype Animated
    • Icon
  • Legal
    • Subscription Terms of Service
    • Cloud Terms of Service
    • Frameworks
Powered by GitBook

We are Realmac Software. We make nice things.

On this page
  • Basic Example

Was this helpful?

Edit on GitHub
Export as PDF
  1. Elements Language
  2. Element Pack

Collections

Previousrw.propsNextData collections in Hooks.js

Last updated 3 months ago

Was this helpful?

Collections are a flexible way to create datasets for your element. You can add multiple collections to your elements.

To add data collections to your element you must first create a collections folder at the root of your element.

A public with a growing collection of Element Dev Packs is now available, including Collection examples!

Example structure

/com.company.element.element-name
  /collections
    /{data-collection-name}
      • info.json
      • properties.json

Inside the collections folder you must create a folder with the name of your data collection. Inside the data collection folder you must create both a info.json and properties.json file.

Basic Example

If we want to create an data collection for features we need to create the following structure in your element:

/com.company.element.element-name
  /collections
    /features
      • info.json
      • properties.json

Info.json

We then need to identify this data collection with RapidWeaver. To do this we must add the following code to the info.json file.

{
  "identifier": "com.company.element.features",
  "title": "Features"
}

Properties.json

To add properties to our collection we need to describe the fields for each item added to our features collection.

Data collection properties are described in the same way as Element properties.

This means we must create a properties.json file and describe our properties in exactly the same way as Element properties.

So, given that a feature should have a title, description, and icon, we should add the following to properties.json:

{
  "groups": [
    {
      "title": "Feature",
      "properties": [
        {
          "title": "Title",
          "id": "title",
          "text": {
            "default": ""
          }
        },
        {
          "title": "Description",
          "id": "description",
          "textArea": {
            "default": ""
          }
        },
        {
          "title": "Icon",
          "id": "icon",
          "resource": {}
        }
      ]
    }
  ]
}

With this all setup your element will have a Features data collection that allows the user to add unlimited items with a title, description, and icon.

Note: all properties available to Elements are also available to data collections. Read the for more information.

properties.json docs
repository on GitHub
Example Collection view with four records.