Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty template - error logs ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sat Sep 12, 2020 12:01 am    Post subject: Smarty template - error logs ? Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Sep 24, 2020 5:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Fri Sep 25, 2020 12:20 am    Post subject: Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Sun Sep 27, 2020 1:14 am    Post subject: Reply with quote

"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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP