Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

How do I add multiple entries with the help of one file

Started by Muut Archive 11 years ago · 2 replies · 392 views
11 years ago

I want to add a team members section in my theme, I want to have one file that would contain multiple entries of members and add it to the template, Is there a way to do this by using a .yaml file or is there any other way?

11 years ago

You could just create a user/config/members.yaml file and in that have an array of members.

YAML
kaladan:
  name: kaladan
  email: kaladan@mail
  image: kaladan.png
  bio: simple bio
joeblow:
  name: Joe Blow
  email: j[email protected]
  image: joe.jpg
  bio: joe bio

Then you can use this in your template via:

TWIG

{% for member in config.members %}
Name: {{ member.name }}
Email: {{ member.email }}
{% endfor %}
---
11 years ago

Thank you. This will make my work a lot easier.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 676 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5337 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago