Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

noppingen/grav-plugin-file_exists

Repository files navigation

Grav "File Exists" Plugin

File Exists is a plugin for the Grav CMS that allows to check the existance of a file in the filesystem without adding PHP code to your template.

Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to file_exists.

You should now have all the plugin files under

/your/site/grav/user/plugins/file_exists

NOTE: This plugin is a component for Grav which requires Grav and a theme to be installed in order to operate.

Config Defaults

enabled: true

Usage

In your Twig template use file_exists() to test for the existance of files. The plugin returns a boolean value:

  • true if the specified file exists
  • fals if it does not exist

Example

Display _header.jpg if it exists in folder of current page:

{# Needs plugin "File Exists" (https://github.com/noppingen/grav-plugin-file_exists) #}
{% set current_path = page.path() %}
{% if file_exists(current_path ~ "/_header.jpg") %}
 <img title='Header - {{ page.title }}' src='{{ page.url }}/_header.jpg'>
{% endif %}

Link

More information (German): https://www.onderka.com/computer-und-netzwerk/grav-plugin-file_exists

About

"File Exists" plugin for Grav CMS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /