[PHPTAL] Re: PHPTAL Digest, Vol 37, Issue 9
Wallace McGee
wallace at petrosys.com.au
Tue Mar 25 00:23:36 CET 2008
I have used global variables via tal:define="global ..." to keep track
of the last value printed so I can do sub-total break:
Defore the loop:
<tal:block tal:define="global lastAgreement string:x" />
During the loop:
<tal:block tal:condition="php:oneRow['AGREEMENT_UID']!=lastAgreement">
...
</tal:block>
<tal:block tal:define="global lastAgreement oneRow/AGREEMENT_UID" />
phptal-request at lists.motion-twin.com wrote:
> Send PHPTAL mailing list submissions to
> phptal at lists.motion-twin.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.motion-twin.com/mailman/listinfo/phptal
> or, via email, send a message with subject or body 'help' to
> phptal-request at lists.motion-twin.com
>
> You can reach the person managing the list at
> phptal-owner at lists.motion-twin.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of PHPTAL digest..."
>
>
> Today's Topics:
>
> 1. Table column with difference value (Krzysztof Zaleski)
> 2. Re: Table column with difference value (Krzysztof Sikorski)
> 3. Re: Table column with difference value ( Iv?n -DrSlump- Montes )
> 4. Re: Table column with difference value (Levi Stanley)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 23 Mar 2008 23:02:58 +0100
> From: "Krzysztof Zaleski" <cshyshtof at gmail.com>
> Subject: [PHPTAL] Table column with difference value
> To: phptal at lists.motion-twin.com
> Message-ID:
> <cec6a1a60803231502l4f494191m99921db09c0e1846 at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
>
> Let's assume I have a table (generated from DB) with 3 columns with daily
> receipts from three shops. Fourth column is a sum of all three values (sum
> is calculated by SQL query). Now, I would like to add next column showing
> the difference between the sum of current day, and the value from previous
> day. I tried using tal:define in various ways, but I either get the message
> that some variable is redefined twice, or some variable definition is
> missing. From my tests it seems that I cannot accomplish this task with
> tal:define. If I could do something like tal:php :-) it would be perfect.
> The whole idea is rather simple, but I don't know how to store previous
> value from one row iteration to another. Any ideas?
>
> Rgrds,
> Krzysztof
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20080323/ac94b488/attachment-0001.htm
>
> ------------------------------
>
> Message: 2
> Date: Sun, 23 Mar 2008 23:19:38 +0100
> From: "Krzysztof Sikorski" <dreamer.pl at gmail.com>
> Subject: Re: [PHPTAL] Table column with difference value
> To: "Template Attribute Language for PHP"
> <phptal at lists.motion-twin.com>
> Message-ID:
> <568622b0803231519o40e4d26ale030107cb6e2063c at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
>
>> If I could do something like tal:php :-) it would be perfect.
>>
> Your can use php code in expressions:
> http://phptal.motion-twin.com/manual/en/split/ar05s07.html#tales-php
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 23 Mar 2008 23:55:34 +0100
> From: " Iv?n -DrSlump- Montes " <drslump at pollinimini.net>
> Subject: Re: [PHPTAL] Table column with difference value
> To: "Template Attribute Language for PHP"
> <phptal at lists.motion-twin.com>
> Message-ID:
> <2e5ad57a0803231555n17a61820h980d906632e31290 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> I haven't tried it but perhaps something like this can give you the result:
>
> <tr tal:repeat="item data">
> <td tal:content="item/total">Total</td>
> <td tal:content="php: lastTotal">Last Total</td>
> <?php $ctx->lastTotal = $ctx->item['total']; ?>
> </tr>
>
> or
>
> <tr tal:repeat="item data">
> <td tal:content="item/total">Total</td>
> <td>
> <?php
> echo $lastTotal;
> $lastTotal = $ctx->item['total'];
> ?>
> </td>
> </tr>
>
> ivan
>
> On Sun, Mar 23, 2008 at 11:19 PM, Krzysztof Sikorski
> <dreamer.pl at gmail.com> wrote:
>
>>> If I could do something like tal:php :-) it would be perfect.
>>>
>> Your can use php code in expressions:
>> http://phptal.motion-twin.com/manual/en/split/ar05s07.html#tales-php
>>
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL at lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
>>
>>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 23 Mar 2008 19:54:21 -0400
> From: "Levi Stanley" <levi at eneservices.com>
> Subject: Re: [PHPTAL] Table column with difference value
> To: "Template Attribute Language for PHP"
> <phptal at lists.motion-twin.com>
> Message-ID:
> <63da41d60803231654k6e240006s60d4e84785feec77 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Why not just do all of it in SQL? Or you can iterate everything into an
> array, before you push it to the presentation layer.
>
> ...
>
> $data = array();
> while($row = $result->doSelect($criteria)){
> array_push($data, array( '3-shop-sum' => $row['1st-shop'], '2nd-shop' =>
> $row['2nd-shop'], '3rd-shop' => $row['3rd-shop'], '3-shop-sum' =>
> $row['3-shop-sum'], 'previous-day' => $previous);
> $previous = $row['3-shop-sum'];
> }
>
> $template->set('list', $data);
>
> ...
>
> On Sun, Mar 23, 2008 at 6:02 PM, Krzysztof Zaleski <cshyshtof at gmail.com>
> wrote:
>
>
>> Hi,
>>
>> Let's assume I have a table (generated from DB) with 3 columns with daily
>> receipts from three shops. Fourth column is a sum of all three values (sum
>> is calculated by SQL query). Now, I would like to add next column showing
>> the difference between the sum of current day, and the value from previous
>> day. I tried using tal:define in various ways, but I either get the message
>> that some variable is redefined twice, or some variable definition is
>> missing. From my tests it seems that I cannot accomplish this task with
>> tal:define. If I could do something like tal:php :-) it would be perfect.
>> The whole idea is rather simple, but I don't know how to store previous
>> value from one row iteration to another. Any ideas?
>>
>> Rgrds,
>> Krzysztof
>>
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL at lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
>>
>>
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20080324/3a1ab839/attachment-0001.htm
>
> ------------------------------
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
>
> End of PHPTAL Digest, Vol 37, Issue 9
> *************************************
>
More information about the PHPTAL
mailing list