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

Outputting data from custom fields

admin first-time

Started by Cedric W 8 years ago · 1 replies · 732 views
8 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
8 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 Jerry Hunt, 4 days ago
2 99 16 hours ago
General · by pamtbaau, 21 hours ago
1 63 21 hours ago
General · by Andy Miller, 1 day ago
0 48 1 day ago
General · by Marcel, 12 months ago
6 357 5 days ago
General · by Duc , 6 days ago
3 45 6 days ago