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

Include external files

Started by Muut Archive 11 years ago · 4 replies · 377 views
11 years ago

Hi. I generate a new email every day (avoid spamming). All old addresses are deleted. I could include the plain text files containing only the current address in my WordPress pages without a problem ... because of php.
Is there any possibility to get this feature working in Grav / Markdown, too, as it is a showstopper for me in using Grav. I already tried the solutions at http://assemble.io/docs/Markdown.html, but they did not work.
Whould be great if this would work.
Greetz, Gabriel

11 years ago

Add.: Some pseudocode:

TWIG

[Write me](mailto:{{../external/file/here}})
---
11 years ago

This could easily be done with a very simple plugin that simply installed a twig extension which in turn wrapped a simple php include.

Alternatively, you could simply put your email into a custom yaml file in /user/config.

For example create a file called: /user/config/gabbalo.yaml (name doesn't matter really, but is used when you retrieve the value).

In that file you simply have this:

TXT

Then in your content (as long as you have Twig processing enabled, and also Twig first processing, you can put this in your content:

TWIG
[Write me](mailto:{{ config.gabbalo.email }})

BTW, if you put this in a twig template in your theme, rather than page content, you don't need that page processing stuff.

That will effectively do the same thing without the security implications of including arbitrary files.

11 years ago

email: [email protected] -> config/email.yaml
and <a href="mailto:{{ config.email.email }}">{{ item.text }}</a> in the template works like a charm.
Thanks for your help, even if I now must make a workaround to fit this in my environment.
The file is placed in the docroot and contains only the address, not the 'email:' part. I already tried to use symlinks, but that broke the whole page xD
Perhaps I will be able to modify the script to create the correct file-content at the correct location (additionally to the original file).
Again, thank you for your quick advice =)

11 years ago

you should be able to symlink that one file:

TXT
$ ln -s email.yaml user/config/email.yaml

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1334 9 years ago
Archive · by Muut Archive, 9 years ago
2 925 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2939 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago