|
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 |
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sat Sep 12, 2020 12:01 am Post subject: Smarty template - error logs ? |
|
|
Hi, ive got a two-part question.
1) ERROR LOG :-
/templates/compiled/7091ef2c494c61fd62755ebbf57292c93dc68ca8_0.file.header.tpl.php on line 42
if i have two /header.tpl filles in separate directories, is there a way to have the error logs show the FULL path ? and not just all looking at the compiled path and looking like 1 directory ?
I've copied the 2nd header file & renamed it to global_header.tpl - Will slowly modify my templates to use the new header.
2) is there a way to add code to a template, to force text to be logged in the php error logs ?
EDIT:
3) Is it possible to improve future versions of Smarty ?
Ive got this error:- Trying to get property of non-object in (path name etc )
It will be useful to give the variable name - eg $bob - Then I/we can easily see the name of the variable/array that has a prioblem.
Thanks. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Sep 24, 2020 5:01 pm Post subject: |
|
|
1. Each compiled template file has a reference to the file it was compiled from.
Literally.
Quote: | Code: | /* Smarty version 3.1.32, created on 2020-07-31 11:46:55
from '…/inc/templates/FormBuilder/image.smarty' */ |
|
2. Yes. See "Extending Smarty" section in the documentation, also you can use error_log() in templates as normal. (Unless SmartySecurity is in effect.)
3. That's a problem in YOUR code - you passed a non-object where object was expected. Use type hinting, help language help you to find your bugs. |
|
Back to top |
|
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Fri Sep 25, 2020 12:20 am Post subject: |
|
|
AnrDaemon wrote: | 1. Each compiled template file has a reference to the file it was compiled from.
Literally.
Quote: | Code: | /* Smarty version 3.1.32, created on 2020-07-31 11:46:55
from '…/inc/templates/FormBuilder/image.smarty' */ |
|
2. Yes. See "Extending Smarty" section in the documentation, also you can use error_log() in templates as normal. (Unless SmartySecurity is in effect.)
3. That's a problem in YOUR code - you passed a non-object where object was expected. Use type hinting, help language help you to find your bugs. |
Thanks for number 1 & 2 - I'll look at them..
However - with number 3 _ it will be useful to tell me what the variable is
EG - Foreach ($blob as $x -> $y)
it will tell me - Non object in property $blob - It tells me that $blob is the variable / array / object / whatever that is in question..
I know how to find the template (compiled & non compiled) - & i can work out which line is the matter. But if i'm working with 2-3 variables in a few lines of code - it will be good to easily identify which is causing the problem. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun Sep 27, 2020 1:14 am Post subject: |
|
|
"It will be useful to tell me what the variable is:
e.g. - Foreach ($blob as $x -> $y)
If i'm working with 2-3 variables in a few lines of code - it will be good to easily identify which is causing the problem."
This is what I do: add whitespace.
If it is Smarty code, this:
Code: | {foreach
$FOO
as
$bar}
|
If PHP code:
Code: | foreach(
$FOO
as
$bar){
//code
}
|
That way, distinct line numbers are associated with each variable. |
|
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
|