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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Displaying List Data

Started by Dan Hart 9 years ago · 2 replies · 831 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 Jerry Hunt, 4 days ago
2 80 9 hours ago
General · by pamtbaau, 14 hours ago
1 51 14 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago