On 23-04-2009 at 02:17:50 Jason La <jaso...@gmail.com> wrote:

Is possible to store templates in a database instead of the file
system, and how would I go about doing that?

You can use PHPTAL->setSource() in current stable release.

In version 1.2.0 you can create your own SourceResolver class which will load 
templates on demand, e.g:

class MyDBSource extends PHPTAL_SourceResolver
{
 public function resolve($path)
 {
    $result = database_fetch_one_row("SELECT source FROM templates WHERE path = 
?", $path);
    if ($result)
    {
       return new PHPTAL_StringSource($result['source'], $path);
    }
    return null;
 }
}

$phptal->addSourceResolver(new MyDBSource());
$phptal->setTemplate('/my/database/fake/path');

--
regards, Kornel



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

Reply via email to