Hi James,

I didn't think it was possible to nest tales modifiers because the
parser assumes that anything after the modifier is the subject that
needs modifying.  Maybe I'm wrong but it doesn't matter - I've run
into this before and here's what I did (using your code):

<tal:block tal:define="global prodSellPrice
php:prodRow.getProductPrintableSellPrice()"/>
<td tal:content="money: prodSellPrice"></td>

The <tal:block/> could be another <td/> with an tal:omit-tag in it
but...I like using tal:block if I'm just defining a variable.  So the
TAL variable gets defined to the php: value, then the money: modifier
will format the TAL variable.  I haven't tried doing the define in the
<td/> tag - I just like to keep that stuff separated.

If you HAVE to have nested modifiers then, because the money: modifier
comes before the php: modifier, you could regex the $src argument for
modifiers and handle the nesting yourself in the tales_money function
- but I'm not sure how to handle modifiers inside a tales function.

Later,
Patrick

On Dec 24, 2007 6:00 AM,  <[EMAIL PROTECTED]> wrote:
> Send PHPTAL mailing list submissions to
>         phptal@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
>         [EMAIL PROTECTED]
>
> You can reach the person managing the list at
>         [EMAIL PROTECTED]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of PHPTAL digest..."
>
>
> Today's Topics:
>
>    1. PHP Tales custom modifiers syntax (James McLean)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 23 Dec 2007 23:07:00 +1030
> From: "James McLean" <[EMAIL PROTECTED]>
> Subject: [PHPTAL] PHP Tales custom modifiers syntax
> To: phptal@lists.motion-twin.com
> Message-ID:
>         <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Howdy,
>
> I'm building a few custom tales modifiers to use in my templates but
> i've run into an issue with the syntax to use in the actual function
> itself. What i've attempted to build is a tales function that formats
> a number in the correct format for display on the site. There is an
> example in the PHPTal manual but it must be based on an old version of
> PHPTal because it fails.
>
> What I have is this:
> function phptal_tales_money($src, $nothrow) {
>     $src = trim($src);
>     return 'sprintf("%01.2f", ' . PHPTAL_TalesInternal::path($src,
> $nothrow) . ')';
> }
>
> Using the static path method works as expected in another custom tales
> function i've created, however when I use the new money: type it fails
> to handle the nested php: tales.
>
> This is the PHPTal:
> <td tal:content="money: php: prodRow.getProductPrintableSellPrice()"></td>
>
> Generated Template PHP which clearly generates a parse error:
> <td><?php echo phptal_escape(sprintf("%01.2f", $ctx->php:
> prodRow->getProductPrintableSellPrice()), ENT_QUOTES, 'UTF-8') ?></td>
>
> If anyone could provide any tips on how to do it with a later version
> of PHPTal that would be most appreciated.
>
> Cheers,
>
> James
>
>
>
> ------------------------------
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
>
> End of PHPTAL Digest, Vol 34, Issue 4
> *************************************
>

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to