SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm preparing to embark on my most ambitious PHP project yet (a completely dynamic database driven web site combining news, user profiles, comments, columns and much more) and have decided that the project urgently needs some kind of template system to allow the coders to code it up without having to worry about presentation.

    FastTemplate looks to me like the ideal solution - it's a template class sytem that allows template files to define the look of pages, while your own PHP code defines the content. Unfortunately the FastTemplate site has not been updated since PHP4 came out, and running the class under PHP4 introduces some unpleasant problems.

    Here's a set of links so people know what I'm talking about:I also found a couple of threads on the problems with FastTemplate and PHP 4 here:

    http://www.phpbuilder.com/forum/read...&thread=110353
    http://lists.omnipotent.net/php3/200002/msg02306.html

    I've tried the advice in those posts but haven't managed to get it working yet. Has anyone here had any experience with this class - especially using it in PHP 4? Also, does anyone know of a good alternative that works with PHP 4?

    Cheers,

    Skunk

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Progress: A bit more digging around turfed up this: http://lists.omnipotent.net/php3/200002/msg02318.html
    This caused my about half a day of frustration, figured it out, felt
    odd that the regex started working this way, felt stupid about the solution.
    Funny thing is is that it seems (PHP4) to affect all the pattern matching
    in this subtle fashion. Or wait this just occured to me, I could have just
    replaced the ereg with a preg, oh well. There is a vague bug report about this for,
    I think, PHP 4b1, which was left unresolved.

    In class.FastTemplate about line 190-200 in the
    parse_template function, the original line looks like this,

    $template = ereg_replace("{$key}","$val","$template");

    replace it with,

    $key = "{" . $key . "}";
    $template = ereg_replace("$key","$val","$template");

    I dunno, seems really hackish, but it works fine now, I thought
    maybe doing the string concatenation would slow things down a
    wee bit, but it doesn't make a difference that one can notice.

    Jody Stephens
    Tattered Cover Book Store
    This has fixed part of the problem, but I'm still having problems with the dynamic rows demo that comes with the FastTemplate package
    Last edited by Skunk; Feb 20, 2001 at 11:48.

  3. #3
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved I'm using the template class from phpLib instead, it's much more versatile, easier to use, has better performance and works with PHP 4

    For anyone who wants to give it a go you can find it here:

    http://phplib.netuse.de/

    The official documentation for the Template class is here:

    http://phplib.netuse.de/documentatio...n-4.html#ss4.2

    But I much prefer the tutorial here for figuring out how to use the class:

    http://www.phpbuilder.com/columns/david20000512.php3


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •