Is it posible to test if a file exists inside twig template ?
Archive
To my knowledge, you'd have to accomplish that with a Twig extension (via a plugin). Google returns some ideas. There are at least three twig-related plugins in the repository that you can look at for guidance.
Would be simple to write a custom twig filter that took a file path and tested if file_exists()
@Perlkönig @rhukster thanks, I will write my own first twig filter I start with :
https://learn.getgrav.org/cookbook/plugin-recipes#output-some-php-code-result-in-a-twig-template
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1359 | 9 years ago | ||
| 2 | 936 | 9 years ago | ||
| 2 | 4066 | 9 years ago | ||
| 1 | 2955 | 9 years ago | ||
| 3 | 1121 | 9 years ago |