imponeer/smarty-foreachq

重写的Smarty foreach变体,最初是为xoops使用而发明的,但如今在许多基于PHP的CMS中也被使用

v1.1.7 2023-07-01 11:32 UTC

This package is auto-updated.

Last update: 2024-09-01 11:20:13 UTC


README

License GitHub release Maintainability PHP Packagist

Smarty ForeachQ

重写(由于原始使用GPLv2+许可证)Smarty foreach变体,最初是为使用XOOPS而发明的,但如今在许多其他基于PHP的CMS中也被使用(如ImpressCMS)。

查看,Xoops中此smarty插件的原始版本,以了解该插件存在的原因。

安装

要安装和使用此包,我们建议使用Composer

composer require imponeer/smarty-foreachq

否则,您需要手动包含来自src/目录的文件。

在Smarty中注册

如果您想在此项目中使用此包中的扩展,您需要使用registerPlugin函数Smarty中进行注册。例如

$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']);

从模板中使用

如何使用示例

  {foreachq from=$data item=el}
    {$el}
  {/foreachq}

如何贡献?

如果您想添加一些功能或修复错误,您可以创建分支、修改并创建拉取请求。如果您不确定如何操作,请尝试互动GitHub教程

如果您发现任何错误或有任何问题,请使用问题标签,并在那里写下您的问题。