如何计算 ezpublish 中的数组键?
我在计算 ezpublish 中的数组键值时遇到问题,其 php 函数是
array_count_values();
我需要在 ezpublish 中使用类似的函数。 ezpublish 中是否有任何运算符,或者我也必须为其进行扩展?
i have a problem counting array keys value in ezpublish whose php function is
array_count_values();
i need a similar function in ezpublish. Is there any operators in ezpublish or i have to make an extension for it too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
经过长时间的研究,我发现,没有任何 ezpublish 模板运算符用于
array_count_values();
我们必须为其进行扩展。下面的链接给出了扩展的过程。http://blog.developeronhire.com/using- custom-php-functions-in-ez-publish-templates/
谢谢大家
After research for long time i found that, there is no any ez publish template operators for
array_count_values();
we have to make an extension for it. And process of making extension is given in the link below.http://blog.developeronhire.com/using-custom-php-functions-in-ez-publish-templates/
Thank you all
计数运算符就是您在这里寻找的内容,它出现:
文档中有关此运算符的更多信息:http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Variable -and-type-handling/count
一般来说,您也可以随时在 eZ Publish 社区门户上提出您的问题:http ://share.ez.no (但我想你已经知道这个地方了;))
希望它有帮助,
干杯,
The count operator is what you are looking for here, it appears :
More on this operator in the documentation : http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Variable-and-type-handling/count
Generally, feel free to also drop your questions on the eZ Publish Community Portal : http://share.ez.no (but i think you already know this place ;) )
Hope it helps,
Cheers,
您可以将 php 函数声明为 新模板运算符供模板使用。
将其添加到 template.ini 覆盖文件中。
You can declare the php function as a new template operator for templates to use.
Add it to the template.ini override file.
正如 Nicolas 所说,您可以将任何 PHP 函数映射到模板运算符,如果:
有一个强制参数和其他可选参数,但我
记得它会生成 PHP 警告并且可选参数
将被忽略)
文档:http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Configuration-files/template.ini/PHP/PHPOperatorList
所以做你想做的事情真的很容易因为 array_key_values() 是一个很好的候选者并且符合要求。
As said by Nicolas, you can map any PHP functions to a template operator if :
having one mandatory parameter and others which are optional but I
can remember that it generates PHP warnings and that the optionals parameters
will be ignored)
Documentation : http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Configuration-files/template.ini/PHP/PHPOperatorList
So doing what you want is really easy since array_key_values() is a good candidate and matches the requirements.
尝试这个
用法
try this
usage
如果您需要使用 PHP 本机函数,您确实应该使用此扩展: http://projects.ez.no/wrap_operator
您只需在扩展的 ini 文件中启用所选功能并在模板中使用它即可。
例如:
它会救你的命!
If you need to use PHP native functions, you really should use this extension : http://projects.ez.no/wrap_operator
You just have to enable the selected function in the ini file of the extension and to use it in your templates.
For example :
It will save your life !
如果将其添加到站点扩展的 template.ini 中不起作用,只需创建一个自动加载。它们的创建非常简单,也是我经常添加我需要的任何 php 函数的方式。您不需要用于自动加载的新扩展,只需将其添加到 autoloads 目录中的现有扩展即可。 不要忘记在 eztemplateautoload.php 文件中声明您的自动加载,您可能还需要将其中之一添加到您的 autoloads 目录中。
If adding it to the template.ini of your site's extension does not work, just create an autoload. They are very simple to create and is how I often add any php function I need. You don't need a new extension for the autoload, just add it to your existing extension in the autoloads directory. Don't forget to declare your autoload in the eztemplateautoload.php file, you will likely have to add one of those to your autoloads directory too.