https://github.com/imponeer/smarty-foreachq
Rewritten @smarty-php foreach variant that was invented for use in @xoops, but nowadays is used in some other PHP based CMS'es (like @ImpressCMS!)
https://github.com/imponeer/smarty-foreachq
foreach hacktoberfest smarty smarty-plugins
Last synced: 3 months ago
JSON representation
Rewritten @smarty-php foreach variant that was invented for use in @xoops, but nowadays is used in some other PHP based CMS'es (like @ImpressCMS!)
- Host: GitHub
- URL: https://github.com/imponeer/smarty-foreachq
- Owner: imponeer
- License: mit
- Created: 2021-02-02T18:30:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T11:05:30.000Z (12 months ago)
- Last Synced: 2024-10-01T15:27:27.704Z (9 months ago)
- Topics: foreach, hacktoberfest, smarty, smarty-plugins
- Language: PHP
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](LICENSE)
[](https://github.com/imponeer/smarty-foreachq/releases) [](https://codeclimate.com/github/imponeer/smarty-foreachq/maintainability) [](http://php.net)
[](https://packagist.org/packages/imponeer/smarty-foreachq)# Smarty ForeachQ
Rewritten (due that original use GPLv2+ license) [Smarty](https://smarty.net) foreach variant that was invented for use in [XOOPS](https://xoops.org), but nowadays used in some other PHP based CMS'es (like [ImpressCMS](https://impresscms.org)!).
See, [original version of this smarty plugin in Xoops](https://github.com/XOOPS/XoopsCore25/blob/v2.5.8/htdocs/class/smarty/xoops_plugins/compiler.foreachq.php) to see more accurate description why this plugin exists.
## Installation
To install and use this package, we recommend to use [Composer](https://getcomposer.org):
```bash
composer require imponeer/smarty-foreachq
```Otherwise, you need to include manually files from `src/` directory.
## Registering in Smarty
If you want to use these extensions from this package in your project you need register them with [`registerPlugin` function](https://www.smarty.net/docs/en/api.register.plugin.tpl) from [Smarty](https://www.smarty.net). For example:
```php
$smarty = new \Smarty();
$foreachqOpenPlugin = new \Imponeer\Smarty\Extensions\ForeachQ\ForeachQOpenTagCompiler();
$foreachqClosePlugin = new \Imponeer\Smarty\Extensions\ForeachQ\ForeachQCloseTagCompiler();
$smarty->registerPlugin('compiler', $foreachqOpenPlugin->getName(), [$foreachqOpenPlugin, 'execute']);
$smarty->registerPlugin('compiler', $foreachqClosePlugin->getName(), [$foreachqClosePlugin, 'execute']);
```## Using from templates
Example how to use it:
```smarty
{foreachq from=$data item=el}
{$el}
{/foreachq}
```
## How to contribute?If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try [interactive GitHub tutorial](https://skills.github.com).
If you found any bug or have some questions, use [issues tab](https://github.com/imponeer/smarty-foreachq/issues) and write there your questions.