Closed omniperspective closed 5 years ago
I'm not sure what you mean by "external" YAML data. Do you want to access the meta headers of a arbitrary page? Try e.g. pages["sub/page"].meta
. Just to be sure, you're trying to do this in a Twig template (i.e. a .twig
file, not .md
), right? What error message shows up in your webserver's error.log
? If you remove the lines in question, does the website work? The syntax seems to be correct, but are you sure that the page you're trying to include actually exists? Double check this by printing out the page ID (i.e. {{ "personalia/#{meta.language}/#{meta.medewerker}" }}
).
some text
I get the content of en external markdownfile like testfile.md with {{ "testfile.md"|content }}
But how to get variable1 ? {{ "testfile.md"| meta.variable1 }} will get nothing
Try this:
{{ pages["testfile"].meta.variable1 }}
I'm ashamed, it works. Was it that simple......
Zucht Henk.
Great to hear that! 👍 If you have any other question, don't hesitate to ask 😃
For the export as ..
I use {{ "testfile.md"|content }} to get the contect {{ pages["testfile"]|content }} this gets the content as well.
What should I use and any reason why so? Would like to learn .. Henk.
Actually neither {{ "testfile.md"|content }}
nor {{ pages["testfile"]|content }}
works 😉 You probably rather mean {{ "testfile"|content }}
and {{ pages["testfile"].content }}
. You should always use {{ "testfile"|content }}
.
{{ pages["testfile"].content }}
works only if the page contents have been parsed already. This is only true if...
{{ "testfile"|content }}
, orPicoParsePagesContent
plugin enabled (please note that we'll remove this plugin with Pico 2.0 due to performance reasons, so you really shouldn't rely on it).Always use {{ "testfile"|content }}
.
This is the bread and butter of text.
in Pico 2.0.2 I'm able to retrieve the data in the data part of the file with
{{ "bagger"|content }}
But I'm now unable to get the data from the YAML part
{{ "bagger"|.meta.variable1 }} gives an error 500
{{ "bagger"|meta.variable2 }} gives an error 500
{{ pages["bagger"].meta.variable1 }} doesn't work in 2.0.2
What is it that I don't understand?
What is the correct syntax to get the YAML variable data?
I'm unable to solve this, please help.
The problem is a really, really small typo: You're using ----
(four dashes) instead of the expected ---
(three dashes) after the YAML Front Matter. Due to this, Pico won't recognize this as a YAML Front Matter (resulting in variable1: "aap" variable2: "noot" variable3: "mies" template: index
getting print out on the page). {{ pages["bagger"].meta.variable1 }}
is the correct syntax.
facepalm ;-( Thanks for the correction.
I want to get the variable metadata (YAML) from a external file.
To get the content I do this:
{{ "personalia/#{meta.language}/#{meta.medewerker}"|content }}
But how do I get an external yaml data (meta.xyz) I only get 500 errors.
Please help, it drives me nuts(!) Thanks in advance for your help Henk.