Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

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

Started by Muut Archive 10 years ago · 2 replies · 274 views
10 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?

10 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 %}
---
10 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago