Forums / General / simple problem - how to get length of an array?
Michal Slocinski
Saturday 13 September 2008 5:34:37 am
Hi,
does anyone know how to get length of an array in .tpl? Maybe it's obvious & stupid question but I can't find answer anywhere, so sorry in advance :-)
Michal
André R.
Saturday 13 September 2008 6:11:15 am
It should probably be mentioned in the array part, but if you scroll down to the 'Variable and type handling', you'll find something:http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom
Saturday 13 September 2008 6:31:03 am
thanks, indeed some reference from 'Arrays' section would be helpful
Pascal Specht
Tuesday 16 September 2008 12:38:00 am
Hello Michal,
you probably found your way around with this. But just in case, did you know that you can add your own functions via your own extension? Look at the http://projects.ez.no/jacextension/downloads tutorial for how to do this. A nice real-world example of doing so is the extension called Swark, which you can find here: http://ez.no/developer/contribs/template_plugins/swark (eZ Publish 3.x) and here: http://ez.no/developer/contribs/template_plugins/swark_for_ez_publish_4 (eZ Publish 4.x)
Happy coding,
</Pascal>
Jérôme Vieilledent
Saturday 04 October 2008 3:51:45 pm
You can add support of the <i>count</i> PHP function as a template operator. You can do that by overriding the template.ini config file. You can embed as many PHP native functions as you want, as long as they accept only one argument.
Gaetano Giunta
Sunday 05 October 2008 6:35:29 am
Maybe I am missing something here, and I appreciate the additional insight given by comments about registering your own template operators, but is this not enough?
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/variable_and_type_handling/count
Principal Consultant International Business Member of the Community Project Board
Sunday 05 October 2008 6:47:21 am
Thats the one I was hinting about earlier in this thread, and Michal correctly got it.. :)
Sunday 05 October 2008 11:55:21 pm
Sorry, I checked the manual too quick...