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

Inject header variable in content

Started by Muut Archive 10 years ago · 2 replies · 393 views
10 years ago

Hi there!

Is it possible to inject a variable, which is stored in the page header from the content area?
What I am looking for is an ability to inject data stored in the page header in the markdown formatted content area.

Like this example:


variable1: inject me


Heading1 of MarkdownText

Some content formatted in Markdown and [# magic code that injects variable "variable1" #] here Markdown Content goes on...

Thanks in advance!

10 years ago

Sure it's simple. First you need to enable Twig processing in the page header, then you just use Twig to output it:

YAML
-  -
title: My Page
process:
  twig: true
variable1: inject me
-  -
# Heading1 of MarkdownText

Some content formatted in Markdown and {{ header.variable1 }} here Markdown Content goes on…
10 years ago

Thank You! Exactly what I've looking for! (and so easy)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1123 9 years ago