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.

Support

How to access variables for simple-events in a Twig template

first-time plugin plugins twig

Started by Marcel de Haas 2 years ago · 2 replies · 77 views
2 years ago

Hi there,

I'm quite new to the world of Grav after some small personal projects in Drupal (long time ago), Hugo and Jekyl. I need the ease of content creation for some none technical users but love the portable setup of Grav.
I have installed the simple-events plugin and modified the overview page of events to create links so I can present the single event. I am writing the template for the single event now but I don't understand how I can get to the values of the plugin. I have tried all the ways I could think of but for example the location will always return '0'

TWIG
    {{ dump(page) }}

    <h1>Naam: {{ page.title }}</h1>
    Naam: {{ page.header.title }}<br/>
    <h3>Datum: {{ page.header.date }}</h3>
    Locatie: {{ page.header.location }}<br/>
    Start: {{ page.simple-events.start }} <br/>
    Start: {{ page.header.simple-events["start"] }}<br/>

Here is a screenshot with the dump in the debugger:
image|547x499

Can anybody point me in the right direction to access these values?

Kind regards,
Marcel

2 years ago

You can access the event values using {{ page.header.simple_event.location }} instead of {{ page.simple-events.start }}. Ensure your plugin is correctly configured to pass the right header values.

2 years ago

@mdehaas:
the location

If you need get the page URL, try this: {{ page.url() }}

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 10 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago