Re: [Tiki-devel] Counting items resulting from items > item list (smarty ?)

Jonny Bradley via TikiWiki-devel <[email protected]>
Newsgroups gmane.comp.cms.tiki.devel
Message-ID <[email protected]>
Hi Bernard

You can use the php count() function http://www.php.net/manual/en/function.count.php in smarty, which you can use as either a function or modifier, and tracker_field_productsboughtChildName i think should be an array, right?

So then it depends if you need unique names, or a total including duplicates (your example doesn't have duplicates, so let's go with total, as that's simpler ;)


  {$childNameCount = 0}

  {foreach $results as $row}
    {$childNameCount = $childNameCount + $row.tracker_field_productsboughtChildName:count}
  {/foreach}

Totally unchecked and untested, but something like that should work :)

jonny



> On 15 Mar 2021, at 06:40, Bsfez Tiki via TikiWiki-devel <[email protected]> wrote:
> 
> Hello,
> 
> (back to business ;-) )
> 
> With the plugin List and the unified index we have a "$count" variable.
> This variable will display the number of results.
> 
> But how can I count the number of items from an item list field within its array ?
> 
> This is the tiki-pluginlist_experiment.php output for one kid (this is an item list field):
> tracker_field_productsboughtChildName_text => "אגם"
> For 2 kids:
> tracker_field_productsboughtChildName_text => "אוריין שחר, ליאור"
> 
> IE: I have items with an item list.
> Item1 name(s): Jonny, Torsteen
> Item2 name(s): Marc
> Item3 name(s) : Bernard, Gary
> Item4 name(s) : Jyhem
> 
> I need a people count (6)
> 
> Any ideas on how to do that ?
> B
> _______________________________________________
> TikiWiki-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.