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.

Archive

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

Started by Muut Archive 11 years ago · 13 replies · 353 views
11 years ago

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

11 years ago

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 :)

11 years ago

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:

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

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

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

11 years ago

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.

11 years ago

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

11 years ago

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

11 years ago

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

11 years ago

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

11 years ago

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

11 years ago

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

11 years ago

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.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago