Re: [PHPTAL] Modifiers Code

2009-01-09 Thread Kornel Lesiński

On 08-01-2009 at 21:47:29 Trent Moyer  wrote:



  ... HTML Code ...


The intent is to make every other row have a class="alt".

This is my code for the modifier:

function phptal_tales_alt( $src, $nothrow )
{
$src = trim($src);
return '( '.phptal_tales($src, $nothrow)." ? 'alt' : null )";
}

The problem that I am having is that this modifier and the example  
modifier
given in the PHPTAL documentation do not work when used with multiple  
options (a
| b | c). The code returned by phptal_tales_alt() is "( Array ? 'alt' :  
null )".


This is because your modifier gets all code, including "| nothing" part, and 
this causes phptal_tales() to return array with each part of the expression.

I've created phptal_tale() function (without 's') that always returns single 
expression, but code it returns is not very elegant (due to limitations of what 
constructs can be used in PHP expression).


To get it working you can also simply leave out the "| nothing" part.

--
regards, Kornel



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


Re: [PHPTAL] Modifiers Code

2009-01-08 Thread Iván -DrSlump- Montes
I think to recall that I could do zebra striping with TAL using something
like this:




That should give you class names of 'row0' and 'row1', which you can style
with CSS. Not the cleanest solution but it did the job.

/imv

On Thu, Jan 8, 2009 at 10:47 PM, Trent Moyer  wrote:

> I recently started using PHPTAL and it has proven very useful. However, I
> am
> having some trouble with the custom modifiers. I would like to use the
> following
> or something similar:
>
> 
>  ... HTML Code ...
> 
>
> The intent is to make every other row have a class="alt".
>
> This is my code for the modifier:
>
> function phptal_tales_alt( $src, $nothrow )
> {
>$src = trim($src);
>return '( '.phptal_tales($src, $nothrow)." ? 'alt' : null )";
> }
>
> The problem that I am having is that this modifier and the example modifier
> given in the PHPTAL documentation do not work when used with multiple
> options (a
> | b | c). The code returned by phptal_tales_alt() is "( Array ? 'alt' :
> null )".
>
> I would like to know the simplest code to add class="alt" to every other
> row
> without setting the other rows to class="", and/or how to code a modifier
> to
> behave with multiple options.
>
>
> ___
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal