Connect a Dynamic Repeater to a Database Collection Using Code

Blocks allows you to connect a CMS database collection to a dynamic repeater. Note that Blocks collections are placeholders that allow you to interact with similar structured collections on your site later.

To connect a dynamic repeater to a collection:

  1. Create or open a Blocks widget through the Widgets and Design menu.

  2. Add a dynamic repeater to your widget: go to the Add  panel and click Layout > Dynamic Repeaters.

  3. Create a collection in Blocks. 

  4. Go to the code section of the widget and import the wix-data module:

    Copy
  5. Query the data in the collection with this syntax (learn more about your app namespace):

    @<yourAppNamespace>/<yourCollecitonName>

    For example, the following function gets strings from a collection named "Titles" and assign them to the text elements in a repeater:

    Copy

Find the repeater ID

An element's ID is displayed in several places:

  • In the Design tab, when you hover over or select an element.
  • In the Layers layers icon panel, when you select an element.
  • In the Properties & Events panel properties and events icon, when you select an element.

See also

For an additional example, refer to the Velo tutorial. While this tutorial focuses on standard repeaters used in site building, the same principles apply to dynamic repeaters in Blocks. When adapting the tutorial for Blocks, make sure to add the app namespace before the collection name in your query.

Did this help?