Re: [Tiki-devel] Counting items resulting from items > item list (smarty ?)
Bsfez Tiki via TikiWiki-devel <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello JM,
Thanks for joining.
> Have you tried "|count" instead of ":count"?
I tried "|count" and "|@count" both returns 13 (instead of 16)
> I have found that the token thing is usually an array, and adding this line :
> {FORMAT(name="something")}{display name="tracker_field_productsboughtChildName" format="trackerrender" default=""}{FORMAT}
> will convert tracker_field_productsboughtChildName into an array. Then you can count the number of items. No need to use variable "something" for anything.
Mmm… interesting and... it works (glu ?)
My plugin list:
{wikiplugin _name=list}
{literal}
{filter content="22" field="tracker_id"}
{filter field="tracker_status" content="o"}
{filter field="tracker_field_productsboughtHolidaySelected_text" exact="חופשת פסח 2021"}
{filter categories="17"}
{output(template="childrenCount.tpl")}
{ALTERNATE()}0{ALTERNATE}
{FORMAT(name="child")}{display name="tracker_field_productsboughtChildName" format="trackerrender" default=""}{FORMAT}
{/literal}
{/wikiplugin}
The childrenCount template:
{$childNameCount = 0}
{foreach $results as $row}
{assign var=childNameCount value = $childNameCount + count($row.tracker_field_productsboughtChildName)}
{/foreach}
{$childNameCount}
Output = 16
Note: that using {assign var=childNameCount value = $childNameCount + count($row.child)} = 13
Incredible… I wonder where we should save this information ? (no time for cookbook) 🥴
Thank you both of you for helping. Now we have a reusable solution !
Bernard
> On 17 Mar 2021, at 13:54 , Jean-Marc Libs <[email protected]> wrote:
>
> Some thoughts lower (nothing tested)
>
> On Mon, Mar 15, 2021 at 5:43 PM Bsfez Tiki via TikiWiki-devel <[email protected] <mailto:[email protected]>> wrote:
> Thanks Jonny,
>
>
> I kept my list plugin as is (was working with the templates/search/list/count template) and create a smarty template with the code you posted.
>
> phpStorm doesn’t like the ":count" and I have a syntax error.
>
> Have you tried "|count" instead of ":count"?
>
>
>
> But this is outputting the items count (13) not the names count (15)
>
> Then I recheck each field and find out that on Tiki22 the output of a item link field is a… token.
> Here the value I have for an item with 3 kids:
> tracker_field_productsboughtChildName => "tokenyvvbvdfbvbzxpyccpzvttbearppucfqz..."
> tracker_field_productsboughtChildName_text => "גפן, מרום"
>
>
> I have found that the token thing is usually an array, and adding this line :
> {FORMAT(name="something")}{display name="tracker_field_productsboughtChildName" format="trackerrender" default=""}{FORMAT}
> will convert tracker_field_productsboughtChildName into an array. Then you can count the number of items. No need to use variable "something" for anything.
>
> Cheers,
> J-M
_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel