Render a file as a ProcessWire template file and cache the output
This method is similar to the
$files->render() method and actually delegates the file
rendering to that method (when creating the cache). The important difference is that this
method caches the output according to WireCache rules for the
$expire argument, rather
than re-rendering the file on every call.
If there are any changes to the source file
$filename the cache will be automatically
re-created, regardless of what is specified for the
Available since version 3.0.130.
// render primary nav from site/templates/partials/primary-nav.php // and cache for 3600 seconds (1 hour) echo $cache->renderFile('partials/primary-nav.php', 3600);
// basic usage $string = $cache->renderFile(string $filename); // usage with all arguments $string = $cache->renderFile(string $filename, $expire = null, array $options = );
Filename to render (typically PHP file).
Can be full path/file, or dir/file relative to current work directory (which is typically /site/templates/).
If providing a file relative to current dir, it should not start with "/".
File must be somewhere within site/templates/, site/modules/ or wire/modules/, or provide your own
|int, Page, string, null|
Lifetime of this cache, in seconds, OR one of the following:
Accepts all options for the
Rendered template file or boolean false on fatal error (and throwExceptions disabled)
Method can throw exceptions on error:
WireException- if given file doesn’t exist
API reference based on ProcessWire core version 3.0.172