An open API service indexing awesome lists of open source software.

https://github.com/philecms/philefolderloop

Loop through a folder of files with Twig
https://github.com/philecms/philefolderloop

philecms-plugin

Last synced: 8 months ago
JSON representation

Loop through a folder of files with Twig

Awesome Lists containing this project

README

          

phileFolderLoop
===================

Loop through a folder of files with Twig

### 0.9.*

This version currently works with 0.9.\*. I havent built the 1.\* version yet!

### Installation

* Install [Phile](https://github.com/PhileCMS/Phile)
* Clone this repo into `plugins/phileFolderLoop`
* add `$config['plugins']['phileFolderLoop'] = array('active' => true);` to your `config.php`

### Usage

In the config there is a list of acceptable file types. The default is for images, so it looks like this:

```
'image_types' => 'jpg|jpeg|svg|png|gif|webp|ico|bmp'
```

You can change this to match the type of files that you want to show.

There will now be a new twig function called `loop`. It takes a path to a folder (relative to the ROOT_DIR, your root installation directory) and grabs all the images in there.

Example:

```twig


{% set images = loop('content/images/products') %}
{% for image in images %}

{% endfor %}

```

Output:

```html


```