Can i pull in some code blocks from within a seperate file?

Hey guys ! ladies :… :smiley: how to include data from within other files. e.g. some file called “DATA” or “CONTENT” ? thanks !

What is the content of these files? Are these just data in some format like JSON? Are they Twig files? are they other Markdown files? Each would have a different solution :slight_smile:

i mean markdown !

You can from Twig. This means that either in a Twig template, or another markdown page (with Twig processing enabled) you can load the data from a page into a variable. For example:

{% set author = page.find('/authors/billy-bloggs') %}

<div class="author-block">
{{ author.content }}
</div>

wow, i’m impressed. thanks.

I have a folder called DATA and i want to pull data from it into a page view. How is this done?

The Page has to be located in the user/pages/ folder to be available to include. If it’s outside for some reason, you could probably use a symbolic link.

it all works just nice, i’m so thankful !

how can i pull in every page inside a pages-folder dynamically ?
thanks

I’m not sure what you mean? Every page dynamically?

yeah, a loop that cycles through a folder and fetches all data there!

if you can upload to github or similar it’s really good to understand what you want :slight_smile:

I think he means iterating through all files in a subfolder and including them in the template. I would also be interested in this :slight_smile:

Grav expects one .md file per folder currently. When we implement multilingual it will support multiple .md files each representing a Lang translation. Also Grav supports media files in a single folder. Beyond this it would probably require a plugin. But should be perfectly doable.