carlcs/craft-glob

There is no license information available for the latest version (v1.0.1) of this package.

Glob plugin for Craft CMS

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:craft-plugin

v1.0.1 2016-02-02 23:01 UTC

This package is auto-updated.

Last update: 2024-11-20 04:58:45 UTC


README

Craft plugin that adds a Twig function to find pathnames in your templates folder matching a pattern.

The plugin uses the PHP glob function internally.

Installation

To install the plugin, copy the glob/ folder into craft/plugins/. Then go to Settings → Plugins and click the "Install" button next to "Glob".

Twig function

glob( path, pattern )

Find pathnames in your templates folder matching a pattern.

{% set plugins = [
    'Asset Metadata',
    'Number Convert',
] %}

{% for plugin in plugins %}
    {% set dirPath = 'tests/' ~ plugin|camel|lower ~ '/' %}

    {% for path in glob(dirPath) %}
        <a href="/{{ path }}">{{ path }}</a>
    {% endfor %}
{% endfor %}

Parameters

path (optional) : The sub-path in craft/templates/ you want to search in.

pattern (optional) : The pattern as described in the PHP glob documentation (Default value is '*.{html,twig}').