| View previous topic :: View next topic |
| Author |
Message |
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 35
|
Posted: Wed Jan 26, 2011 3:03 am Post subject: Uncaught exception 'SmartyException' with message 'Unable to |
|
|
I have been using Smarty 2 for a long time and just uploaded the Smarty 3 files. All my smarty files are stored in a DB instead of in files on the server. Running the test it shows that everything is OK and I can build a sample .php file reading the content from the server but as soon as I add in the database connection it throws the error. Any ideas where to look? I cant seem to find the problem.
// register the resource name "db"
$smarty->registerResource("db", array("db_get_template",
"db_get_timestamp",
"db_get_secure",
"db_get_trusted"));
| Quote: | Smarty Installation test...
Testing template directory...
/home/www/domain.com/public_beta/templates is OK.
Testing compile directory...
/home/www/domain.com/public_beta_template_cache is OK.
Testing plugins directory...
/home/www/domain.com/public_beta/includes/plugins/ is OK.
Testing cache directory...
/home/www/domain.com/public_beta/templates_c is OK.
Testing configs directory...
/home/www/domain.com/public_beta/_temp_builder is OK.
Tests complete. |
| Code: | Fatal error:
Uncaught exception 'SmartyException' with message 'Unable to read template db 'index.tpl'' in /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_template.php:144
Stack trace:
#0 /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_templatecompilerbase.php(67): Smarty_Internal_Template->getTemplateSource()
#1 /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_template.php(260): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template))
#2 /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_template.php(413): Smarty_Internal_Template->compileTemplateSource()
#3 /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_template.php(558): Smarty_Internal_Template->renderTemplate()
#4 /home/www/domain.com/public_beta/includes/Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate()
#5 /home/www/domain.com/public_beta/includes/Smarty.class.php(381): Smarty->fetch('db:index.tpl', N in /home/www/domain.com/public_beta/includes/sysplugins/smarty_internal_template.php on line 144 |
|
|
| Back to top |
|
rodneyrehm Administrator

Joined: 30 Mar 2007 Posts: 698 Location: Germany, border to Switzerland
|
Posted: Wed Jan 26, 2011 8:43 am Post subject: |
|
|
| make sure db_get_timestamp() returns a boolean and assigns an integer to the second argument. If the returned timestamp is not an integer, the source will fail |
|
| Back to top |
|
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 35
|
Posted: Wed Jan 26, 2011 4:27 pm Post subject: |
|
|
| globe wrote: | | make sure db_get_timestamp() returns a boolean and assigns an integer to the second argument. If the returned timestamp is not an integer, the source will fail |
My function is listed below and is returning TRUE and I did an output of the $tpl_timestamp and it is being set as 1294683732 which is Mon, 10 Jan 2011 18:22:12 GMT. In my Cache directory I do see two files.
4cbeb359c70e2c12d7356cc3e5d4d41c0f9983d7.file.index.tpl.php
betastubwirecom^4cbeb359c70e2c12d7356cc3e5d4d41c0f9983d7.file.index.tpl.php
| Code: | function db_get_timestamp($tpl_name, $tpl_timestamp, $Smarty_obj) {
global $gb;
/* DATABASE INFO IS REMOVED */
$tpl_timestamp = strtotime($row['LastUpdatedAt']);
return true;
} |
|
|
| Back to top |
|
rodneyrehm Administrator

Joined: 30 Mar 2007 Posts: 698 Location: Germany, border to Switzerland
|
Posted: Wed Jan 26, 2011 4:31 pm Post subject: |
|
|
| Code: | | function db_get_timestamp($tpl_name, $tpl_timestamp, $Smarty_obj) |
must be
| Code: | | function db_get_timestamp($tpl_name, &$tpl_timestamp, $Smarty_obj) |
|
|
| Back to top |
|
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 35
|
Posted: Wed Jan 26, 2011 11:51 pm Post subject: |
|
|
I did this and its still giving the error. The error is in smarty_internal_template.php at the following lines.
if (!$this->resource_object->getTemplateSource($this)) {
throw new SmartyException("Unable to read template {$this->resource_type} '{$this->resource_name}'");
} |
|
| Back to top |
|
rodneyrehm Administrator

Joined: 30 Mar 2007 Posts: 698 Location: Germany, border to Switzerland
|
Posted: Wed Jan 26, 2011 11:54 pm Post subject: |
|
|
| is db_get_template() also return boolean true? |
|
| Back to top |
|
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 35
|
Posted: Thu Jan 27, 2011 12:03 am Post subject: |
|
|
Ok so I got it thanks to you pointing out the db_get_template and what it returned. The fix (incase anyone comes across this topic) is
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
should be changed to
function db_get_template ($tpl_name, $tpl_source, $smarty_obj) { |
|
| Back to top |
|
rodneyrehm Administrator

Joined: 30 Mar 2007 Posts: 698 Location: Germany, border to Switzerland
|
Posted: Thu Jan 27, 2011 12:07 am Post subject: |
|
|
| redbrad0 wrote: | Ok so I got it thanks to you pointing out the db_get_template and what it returned. The fix (incase anyone comes across this topic) is
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
should be changed to
function db_get_template ($tpl_name, $tpl_source, $smarty_obj) { |
actually you want this:
| Code: | | function db_get_template ($tpl_name, &$tpl_source, $smarty_obj) |
|
|
| Back to top |
|
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 35
|
Posted: Thu Jan 27, 2011 12:20 am Post subject: |
|
|
| Why do you want the & sign? |
|
| Back to top |
|
rodneyrehm Administrator

Joined: 30 Mar 2007 Posts: 698 Location: Germany, border to Switzerland
|
Posted: Thu Jan 27, 2011 12:25 am Post subject: |
|
|
| Code: | function db_get_template ($tpl_name, &$tpl_source, $smarty_obj)
{
// return the template content via referenced argument
$tpl_source = '{assign var="foo" value="bar"}{$foo|escape:"html"}';
// return success state
return true;
} |
|
|
| Back to top |
|
|