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 →

Displaying List Data

Started by Dan Hart 9 years ago · 2 replies · 1158 views
9 years ago

Silly question... I've got my admin setup to have list items but I'm still unsure how to piece it together in my example.html.twig template.

Here's part my YAML:
header.customer_videos:
ordering@: 10
type: list
collapsed: true
label: Videos
fields:
.video:
type: textarea
size: large
label: Video Embed

Here's what I have in my template:
{% for video in page.header.customer_videos %}
<div><p>{{ customer_videos.video }}</p></div>
{% endfor %}

I'm definitely missing something in the for statement, but I'm not sure what??

9 years ago

Hey Dan,

i dont test your stuff, but this should work.

YAML
**Here’s part my YAML:**

header.customer_videos:
    ordering@: 10
    type: list
    collapsed: true
    label: Videos

    fields:
        .video:
            type: textarea
            size: large
            label: Video Embed

**Here’s what I have in my template:**

{% for item in page.header.customer_videos %}
    {{ item.video }}
{% endfor %} 

I just changed video to items for readability (it would also work with video.video)

9 years ago

Hey, thanks for this! I didn't understand things at first but I broke it down a bit and this worked good. Thank you!

Suggested topics

Topic Participants Replies Views Activity
General · by Karmalakas, 1 day ago
2 60 14 hours ago
General · by Hanns Mattes, 2 weeks ago
0 161 2 weeks ago
General · by Dima, 3 weeks ago
1 161 3 weeks ago
General · by pamtbaau, 3 weeks ago
0 266 3 weeks ago
General · by lynbor, 2 months ago
5 751 1 month ago