Re[2]: [PHP] smarty

2004-04-14 Thread Richard Davey
Hello Chris,

Wednesday, April 14, 2004, 3:35:05 PM, you wrote:

CdV I don't understand... how is this:
[snip]
CdV Better than this?
CdV =
CdV $result = mysql_query (SELECT * FROM users WHERE id = '.$_GET[id].');
CdV $row_array = mysql_fetch_array ($result);
CdV $name= $row_array[name];
CdV $address = $row_array[address];
CdV $state   = $row_array[state];
CdV $include(template.tpl);
CdV ---
CdV html
CdV body
CdV Name: ?=$name;?br
CdV Address: ?=$address;?br
CdV State: ?=$state;?br
CdV ...
CdV ===

Because you're injecting variables directly into your HTML, which some
of the time might be ok - but what if the $row_array doesn't contain
name ? You'll raise an Error Warning without first passing it
through some kind of test (or function).

You assume that the PHP short-tags are enabled (? ?) for
echoing variables and while most the time they are, you shouldn't bank
on it in code (incidentally, you don't need the trailing ; on the
short-tag echos).

Sure - these things can be fixed easily, but then that isn't the point
- if you think about it logically, anything Smarty can do, PHP can do
too (well, duh! :)

But what if you want to take your template and perform a bit more than
just mere variable substitution on it? How about highlighting all
words that match a search term, or applying logic to a display block
based on a user status?

Personally I don't use smarty*, but even I can see the benefits it
offers.

* only because I don't build web sites for clients, I build them for
one specific company and we have our own template system in-house.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: Re[2]: [PHP] smarty

2004-04-14 Thread John W. Holmes
From: Richard Davey [EMAIL PROTECTED]

 Because you're injecting variables directly into your HTML, which some
 of the time might be ok - but what if the $row_array doesn't contain
 name ? You'll raise an Error Warning without first passing it
 through some kind of test (or function).

Only if you have error_reporting() set high. If you have a PHP templating
solution, you'd turn error_reporting() down when you included the PHP
templates so you didn't get a warning.

 You assume that the PHP short-tags are enabled (? ?) for
 echoing variables and while most the time they are, you shouldn't bank
 on it in code (incidentally, you don't need the trailing ; on the
 short-tag echos).

You're relying on web-server writable directories when you use Smarty. It's
all a trade-off.

  But what if you want to take your template and perform a bit more than
 just mere variable substitution on it? How about highlighting all
 words that match a search term, or applying logic to a display block
 based on a user status?

You can do this with output buffering and PHP functions. Smarty just
provides you a different interface.

?php start_highlight(); ?
Paragraph Text
?php end_highlight(); ?

vs.

{section type=highlight}
Paragraph Text
{/section}

Yeah, I know that's not quite the Smarty syntax, but you get the idea.
Smarty just provides an easy interface to a lot of these things. It's a
tool, like a lot of others have said. :)

---John Holmes...

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



Re: Re[2]: [PHP] smarty

2004-04-14 Thread Enrico Weigelt
* John W. Holmes [EMAIL PROTECTED] [2004-04-14 11:57:00 -0400]:

snip
 You're relying on web-server writable directories when you use Smarty. 
 It's all a trade-off.

This gets problematic in multi-user environments. You cant use mod_php
anylonger, instead you have to switch to slow cgi+suexec.

Okay, w/ metuxmpm this problem goes away - each vhost can get its 
own uid - but its not 100% stable yet (some rarely situations w/
recoursive requests seem to make MT problems)

   But what if you want to take your template and perform a bit more than
  just mere variable substitution on it? How about highlighting all
  words that match a search term, or applying logic to a display block
  based on a user status?
 
 You can do this with output buffering and PHP functions. Smarty just
 provides you a different interface.

Output Buffering is a bad hack.

The original branch of content-builder's base template system used this,
but I've completely removed this - now there's exactly one print call
at the very end of the page processing. If there have to be snippets
rendered separately, it goes directly into variables or the template-engine's
internal buffers (required when template processing run in a different
process or host)


cu
-- 
-
 Enrico Weigelt==   metux IT services

  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
  cellphone: +49 174 7066481
-
   -- DSL-Zugang ab 0 Euro. -- statische IP -- UUCP -- Hosting --
-

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



Re[2]: [PHP] smarty

2004-04-08 Thread Richard Davey
Hello Robert,

Thursday, April 8, 2004, 4:19:10 PM, you wrote:

RC And people wonder why I feel the need once in while to give you a good
[snipo]
RC when I use it as an example or a point in debate? Really, WHAT IS YOUR
RC PROBLEM? Please get over it!

Whoa Robert, chill out a bit, please! He was only joking, the smiley
should have given it away. I can understand where you are coming from
(being the author 'n all), but I think you may have read into that a
wee bit too much.

Peace people, it's nearly the weekend (unless you live here, in which
case you have tomorrow off anyway :) ... smarty/InterJinn/native
PHP/whatever - pick the one that floats your boat and go sail in it.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: Re[2]: [PHP] smarty

2004-04-08 Thread Robert Cummings
On Thu, 2004-04-08 at 11:50, Richard Davey wrote:
 Hello Robert,
 
 Thursday, April 8, 2004, 4:19:10 PM, you wrote:
 
 RC And people wonder why I feel the need once in while to give you a good
 [snipo]
 RC when I use it as an example or a point in debate? Really, WHAT IS YOUR
 RC PROBLEM? Please get over it!
 
 Whoa Robert, chill out a bit, please! He was only joking, the smiley
 should have given it away. I can understand where you are coming from
 (being the author 'n all), but I think you may have read into that a
 wee bit too much.

In real life as well as in internet messages, a smiley isn't always a
smiley, and I doubt his was meant as a smiley as much as a snide smirk.

 Peace people, it's nearly the weekend (unless you live here, in which
 case you have tomorrow off anyway :) ... smarty/InterJinn/native
 PHP/whatever - pick the one that floats your boat and go sail in it.

Have a good holiday :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re[2]: [PHP] smarty

2004-04-08 Thread Richard Davey
Hello Antonio,

Friday, April 9, 2004, 12:21:15 AM, you wrote:

AM Who the  you tink you're talkin' to, huh! Whatta you
(etc)

Dear God, who unlocked the monkey cage?

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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