Re: store templates files in SQL

From: Date: Tue, 16 Oct 2001 21:01:08 +0000
Subject: Re: store templates files in SQL
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1703@lists.php.net to get a copy of this message
Yes, you probably have to modify that function to have it read the template in a DB... The original function looks like this... function _read_file($filename) { if (!($fd = fopen($filename, 'r'))) { $this->_trigger_error_msg("problem reading '$filename.'"); return false; } flock($fd, LOCK_SH); $contents = fread($fd, filesize($filename)); fclose($fd); return $contents; } So, instead of if (!($fd = fopen($filename, 'r'))) { you would have something like if (!result = mysql_query("select tpl from db where condition")) { to get the same error message when the template can not be found Then... instead of $contents = fread($fd, filesize($filename)); sthg like if ($row = mysql_fetch_array($result)) { $this->_trigger_error_msg("problem reading '$filename.'"); return false; } so that smarty does not crash upon a database error Then finally $contents = $row["tpl"]; return $contents; I didn't try, this is just "on the mail" coding :) Bertrand (aka Katana on EFNet :p) SJA> Does anyone know how or have a function to store the template files in SJA> an SQL database. SJA> I've looked at the smarty code an I believe this is the function that SJA> would have to be changed.. _read_file($resource_name).. SJA> Thanks in advance.

« previous php.smarty.general (#1703) next »