Introduction
GetAsset was first launched in February 2019. It looks inside a folder for a file that was last modified and returns the value in Twig.
Requirements
- Craft 3.1 or above
Examples
Return the last modified file from a directory
Folder path /assets/css contains 3 files, with the following timestamps:
In Twig we pass an array of settings into GetAsset:
This would output:
Return the last modified file from a directory that matches a regex pattern
Folder path /assets/css contains 4 files, with the following timestamps:
In Twig we pass an array of settings into GetAsset. The settings array contains the path and regex pattern:
This example Twig code would output:
Configuration
path
string, required
A valid folder for GetAsset to search
pattern
string, optional, default value '*'
A regex pattern to match
Installation
If you have any issues, feedback or ideas, please feel free to submit an issue on Github.
Read this next