Loop through external data
In the previous lesson you created a page that can dynamically display details for a single article. Now you will create a page that displays a list of articles, along with a link to the article detail page.
Goals
- Build a dynamic article list page that can display data from all articles, along with a link to the corresponding article detail page.
- Use the Loop component to handle multiple records.
- Test the dynamic article list page.
Create an articles page#
- In Uniform, navigate to the Project Map.
- Edit the node Home > Articles.
- Set the following values:
Name Value Node type Composition Composition option Create new Composition type Page - Click Save.
- In the project map, navigate to the node Home > Articles.
- Open the composition.
- Change the following values on the composition:
Field Value Composition Name Article
Connect data resources#
- Open the data resources for the composition.
- Delete the resource Single Article Content.
- Click the button +.
- Click add.
- Enter the following values:
- Click Save.
- Under the field Content Block settings, select one of the entries.
About this step
This entry is only used so the components displayed within Canvas have a value during the authoring process.
- Click Save.
- Add another data resource using the following settings:
- Click Save.
- Under the field Articles settings, enter the following values:
About this step
This entry is only used so the components displayed within Canvas have a value during the authoring process.
- Click Save.
Configure the page#
- On the Hero component, set the following parameters:
Name Mapping Eyebrow text Title Style H2 Description - On the Hero component, map the following parameters:
- On the Breadcrumbs component, set the following parameters:
Name Mapping Display Root Node ticked Display Placeholder Nodes ticked Separator Chevron - Under the Breadcrumbs component, add the Grid component.
- On the Grid component, set the following parameters:
Name Mapping Columns Count 3 Gap X Small - Inside the Grid component there is a slot named Grid Inner. Add the Loop component to this slot.
- In the parameters for the Loop component, click select a data array.
- Select the data resource Articles Content.
- Select the following node:
- Click Connect.
- Inside the Loop component, add the Card component.
- On the Card component, map the following parameters:
- On the Card component, set the following parameters:
- Click Publish.
- On the published site, navigate to the articles page.