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

Text field in frontmatter/header without blueprint

Started by pg@grav 8 years ago · 2 replies · 482 views
8 years ago

I like to add a text field in the header/frontmatter, so that i can use it anywhere in a connected twig something like

in the .md:

YAML
 ---
 title: Service
 menu: Service
 subtext: any text here
 ---

in the twig:

HTML
<div class="aclasshere">
    <p>{{ page.header.subtext }}</p>
</div>

or for more text

YAML
subtexts: 
      txt1: any text here
      txt2: anymore text here

{{ page.header.subtexts.txt1 }}

Is this not possible? Obvoiusly am I getting something wrong with the fields... 😦

last edited 08/19/18 by pg@grav
8 years ago

Are you talking about creating a fillable text field in the Admin interface? In that case, I can't help you (I don't use the Admin module), but I'm pretty sure you need a blueprint for that.

Otherwise, you can obviously just edit the Markdown files directly to add data to the front matter or use something like the Import plugin to pull in external data. You can also put "global" front matter in the site or theme config files.

8 years ago

Thanks Perlkoenig for the hint,
I just wanted to add text at a certain position, and i wondered if i have to declare the fieldname anywhere (without using a blueprint file) before using it OR if i could use any fieldname in the frontmatter of the Markdown without declaring it anywhere before like

subtext: any text here
and in the twig-file
{{ page.header.subtext }}

It looks to me that this is possible and it worked now after a lot of reloads and refreshs

last edited 08/19/18 by pg@grav

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 76 7 hours ago
General · by pamtbaau, 13 hours ago
1 47 12 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