> I've coded in PHP for a while, but I had to leave it for some time. Now
> I'm back, and I'd like to know what's currently being used to separate
> content from presentation, besides Smarty (that seems to be Google's top
> choice)?

I tried Smarty for several weeks and found it was more than I needed, so I
went back to my simpler template system.

I have templates that look like this for example:

> cat userImage.tpl
<!-- userImage Template -->
<tr>
        <td><a href="index.php?i=$imageID"><img
src="thumbnail.php?i=$imageID" $imageHeightWidth border="0"
alt="$imageAltText" title="$imageAltText" /></a></td>
        <td nowrap="nowrap">$userType</td>
        <td align="center">$commentsCountHTML</td>
        <td align="center">$totalPoints</td>
        <td align="center">$timesRated</td>
        <td align="center">$averageRating</td>
</tr>
<!-- End userImage Template -->

Then in my php scripts I call a template like this:

$userImage = getTemplate("userImage");
eval("\$userImage = \"$userImage\";");
$html .= $userImage;

The function being:

function getTemplate($template){
global $Site;
  $html = '';
  $file = $Site['TemplatePath'] . '/' . $template . '.tpl';
  if($handle = fopen($file, "r")){
    while(!feof($handle)){
      $html .= fgets($handle, 4096);
    }
    fclose($handle);
    $html = str_replace("\\'","'", addslashes($html));
  } else {
    die('Fatal: cannot open template ' . $file . '<br />\n');
  }
  return $html;
}

Of course I have no template caching system like Smarty has, but I use
TurkeMM Cache: http://www.turcksoft.com/ and query caching from MySQL 4.  I
also clean my html before output, removing all tabs and newline characters,
and I have zlib.output_compression enabled.  Seems to work well.


--
Greg Donald
http://destiney.com/

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

Reply via email to