Buildin staff page

Hi,
i just need to build a staff page. Each person has its own fields like name, surname, photo and so on. There is few people as staff, less than 10.
I wonder what’s the best way to do it.
It seems flex objects are perfect for this, but seems just a bit overwhelming.
I just need to set in page content a list with fields like:

- name
- surname
- photo

- name
- surname
- photo

and so on
and then render it through my custom twig template. This seems to be the easiest way.

What do you think about?

If there’s no page for each person and list will be available only on one page, then I would do just a simple array in page frontmatter (similar to your example) and access it in that custom template

1 Like

I would do it that way, too. Another way is to create a modular page for each staff member. If there was a requirement for a page per staff member, I would do them as pages.

The best option also depends who is editing and what they are using (Admin UI or file editing).

It does seem like a great use case for Flex Objects but if it’s any consolation, I still don’t understand them enough to use them either. They are at least documented now. However I don’t understand the documentation!

1 Like

You’re both absolute right!
I tried the gallery recipe example and is much easy, but meta info does not show up.
My staff.md file:

---
- myphoto.jpg
- myphoto.jpg.meta.yaml
- myphoto2.jpg
- myphoto2.jpg.meta.yaml
---

# Our staff

## Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

my staff.html.twig template:

{% block content %}
    <section id="staff">
        {{ page.content|raw }}

        <ul>
        {% for image in page.media.images %}
            <li>
                <img src="{{ image.url|raw }}" alt="staff photo" class="staff-photo">
                 <h4 class="staff-name">{{ image.meta.name }} {{image.meta.surname}}</h4>
                <i class="fa fa-plus-circle" aria-hidden="true"></i>
            </li>
        {% endfor %}
        </ul>
    </section>
{% endblock %}

and one of my myphoto.jpg.meta.yaml:

- name: jack
- surname: nicholson
- short_bio: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

image is shown correctly, but meta infos doesn’t

Check here how media meta works. In your case I think you don’t even need the frontmatter list of photos or meta files - Grav automatically finds media if it’s in the same page folder. And in your template just use as you already have. You will need to fix meta file to:

name: jack
surname: nicholson
short_bio: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
1 Like

doh!! putting as you said meta file works!!!
thanks all folks!!!

1 Like