2

I'm using Smarty3 as a template engine and every time I have a PHP warning or notice from within a template it tells me something like this:

Notice: Undefined index: tab in C:\xampp\htdocs\<project>\cms\application\tmp\compile\2ca7baf79266ad8c26c12b77578df81e640dbf89.file.index.phtml.php on line 66

I know how to solve this error, but this message doesn't give me a clue in which file the error occurs. Is there a way for Smarty to tell me the real/original file I have to be looking for to fix the error?

Again, my problem is not that I can't find the error. The problem is that Smarty doesn't tell me in which file and line to find the error.

Also, the error message is not correct, as the following code caused it:

{if count($tab['columns']) > 0} 
...
{/if}

It's not the index thats undefined, but the variable. How can this be?

Roel Jansen
  • 306
  • 2
  • 11
  • it should be in your tpl file check for tab – Sugumar Venkatesan Dec 18 '15 at 09:16
  • You should `$smarty->assign('tab', ...);` somewhere in your code. The value you assign to variable `$tab` is stored internally by Smarty in an array, under the index `tab`. When you write in the template `$tab`, it is translated to something like `$_smarty_tpl->tpl_vars['tab']` in the compiled file. This is why PHP reports *"undefined index: tab"* – axiac Dec 18 '15 at 14:45
  • @axiac, thank you for your comment, but this is not the issue. – Roel Jansen Dec 22 '15 at 08:38

3 Answers3

0

On line 66 you are calling an array with index tab, array[tab], but this index doesn't exist in that array

0

You can enable debugging in Smarty: http://www.smarty.net/docsv2/es/chapter.debugging.console.tpl

José Carlos PHP
  • 1,417
  • 1
  • 13
  • 20
0

The solution to the problem was to update Smarty to the latest version.

Roel Jansen
  • 306
  • 2
  • 11