|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
appel Smarty Rookie
Joined: 27 May 2003 Posts: 29
|
Posted: Mon Jun 23, 2003 4:56 pm Post subject: Wondering about this error |
|
|
I get the following error when I do:
Code: | $smarty->display("index.tpl"); |
assigned template variables:
{$system} Array (1)
error => Array (4)
msg => Undefined offset: 0
code => 8
file => /usr/local/share/smarty/Smarty_Compil...
line => 1266
However, when I do:
Code: | $smarty->fetch("index.tpl"); |
The error goes away.
I have a {$system.module.name} variables in my template, but I process all those variables in PHP before I do the display() part with register_prefilter(). |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jun 25, 2003 5:24 am Post subject: |
|
|
What happens if you clear out your compiled templates and run the test the other way -- first do the fetch test then do the display test. Same thing or has the error sequence been swapped? |
|
Back to top |
|
appel Smarty Rookie
Joined: 27 May 2003 Posts: 29
|
Posted: Thu Jun 26, 2003 2:06 pm Post subject: |
|
|
boots wrote: | What happens if you clear out your compiled templates and run the test the other way -- first do the fetch test then do the display test. Same thing or has the error sequence been swapped? |
No, that's not it. This error only occurs when display() is used. I have managed to re-produce this error using this code:
index.php
Code: | <?
include("Smarty.class.php");
$smarty = new Smarty;
// Raise an error and kill script.
function RaiseError($errno, $errstr, $errfile, $errline) {
// Define array to assign to smarty.
$arrSystem["error"]["msg"] = $errstr;
$arrSystem["error"]["code"] = $errno;
$arrSystem["error"]["file"] = $errfile;
$arrSystem["error"]["line"] = $errline;
// Assign smarty variables.
$GLOBALS["smarty"]->assign("system",$arrSystem);
// Display the template.
$GLOBALS["smarty"]->display("error.tpl");
// Kill execution of script.
exit;
}
set_error_handler("RaiseError");
$smarty->force_compile = true;
$smarty->debugging = true;
$system["module"]["test"] = "whatever";
$smarty->assign("system",$system);
$smarty->display("index.tpl");
?> |
templates/index.tpl
Code: | <html>
<body>
this is {$system.module.test}
</body>
</html> |
templates/error.tpl
Code: | <table border="1" cellpadding="4" cellspacing="0">
<tr bgcolor="#c0c0c0">
<td align="center"><big><b>An error has occured!</b></big></td>
</tr>
<tr bgcolor="#efefef">
<td>
The following error was found while processing this page:<br /><br />
<b>Error message:</b> {$system.error.msg}<br />
<b>Error code:</b> {$system.error.code}<br />
<b>In file:</b> {$system.error.file}<br />
<b>On line:</b> {$system.error.line}<br />
<br />
Please report this error to the system administrator.
</td>
</tr>
</table>
|
The errors I get are:
In debug pop-up window I get:
Code: | assigned template variables:
{$SCRIPT_NAME} /test/index.php
{$system} Array (1)
error => Array (4)
msg => Undefined offset: 0
code => 8
file => /usr/local/share/smarty/Smarty_Compil...
line => 1266
|
From the default error handler I get:
Code: |
An error has occured!
The following error was found while processing this page:
Error message: Undefined offset: 0
Error code: 8
In file: /usr/local/share/smarty/Smarty_Compiler.class.php
On line: 1266
Please report this error to the system administrator
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|