On 14/04/2004, at 11:38 PM, pete M wrote:

How would you code that lot and remember its ALL to do with presentation ?

You must remember, Smarty is just a layer over PHP. All the functions that you've listed exist in pure PHP code somewhere. It would relatively easy to code equivalent templates in PHP.


Taking some random examples from your list:

        {$yesterday|date_format:"%A, %B %e, %Y"}
        becomes
        <?=date("l, F j, Y",$yesterday)?>

        {$articleTitle|lower}
        becomes
        <?=strtolower($articleTitle)?>

        {foreach from=$custid item=curr_id}
        id: {$curr_id}<br>
        {/foreach}
        becomes
        <? foreach($custid as $curr_id): ?>
        id: <?=$curr_id?>
        <? endforeach; ?>

... but there are all pretty easy. How about a harder one like html_options? Just write a quick function, and we're all good:

<?
$customers = array(
        1001 => 'Joe Schmoe',
        1002 => 'Jack Smith',
        1003 => 'Jane Johnson',
        1004 => 'Charlie Brown'
        );

function html_options($options,$name,$selected='')
        {
        echo "<select name='{$name}'>\n";
        foreach($options as $value => $label)
                {
                if($value == $selected) { $s=' selected'; } else { $s=''; }
                echo "\t<option value='{$value}'{$s}>{$label}</option>\n";
                }
        echo "</select>\n";
        }
?>
<?=html_options($customers,"something","1003")?>


The point I'm trying to make here is that Smarty is just an interface to a bunch of PHP functions. Anything you can do with smarty, we can do with PHP. Whilst smarty provides us with some nice basic functions for the above tasks, it's nothing you can't do yourself. A whole heap of the modifiers are straight PHP anyway, and the rest of them are quite simple to reproduce... in fact, I'm sure I have 90% of them tucked away in a library already.


Smarty serves a purpose, and has a market -- that's for sure. But there's no magic here, it's just an interface to a bunch of PHP functions.


--- Justin French http://indent.com.au

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to