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 →

Outputting data from custom fields

admin first-time

Started by Cedric W 9 years ago · 1 replies · 991 views
9 years ago

Im sure this is a very rudimentary question, but I am having issues outputting data stored from my custom fields. Is there something I am missing when trying to output data from a custom text form field? If I have fields in different tabs, is outputting the data the same or do I have to reference that tabs somehow? Hopefully this makes sense.

*note: the text field is only holding one entry. There isn't a list of entries. I know my twig forloop is probably wrong, but this is the only example of outputting data from the custom field I could find. I haven't seen an example in twig documentation or on grav that's the equivalent of <php echo="$location" ?>; most examples are of pulling data out of loop.

my template is event.html.twig

Template:

<div class="date-location">
{% for location in page.overview.location %}
<div class="col">{{ location }}</div>
{% endfor %}
</div>

Blueprint:

overview.location:
type: text
label: Event Location
style: vertical
size: medium

last edited 03/03/18 by Cedric W
9 years ago

I think I figured out my issue. I wasn't prefixing my fields with "header." so my data wasn't storing. Therefore I couldnt see my data. Once I prefixed the field like so in my blueprint,

header.overview.location

I was able to echo out the data like so on the template

<div>{{ header.overview.location }}</div>

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 17 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago