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

How to customize error handling?

 
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
kobe_brylle
Smarty n00b


Joined: 07 Feb 2016
Posts: 2

PostPosted: Wed May 04, 2016 4:03 am    Post subject: How to customize error handling? Reply with quote

Hi guys I wanted to customize my error handling... here's the scenario

1. Define in php controller
Code:

$this->CI->smarty->assign('_setData', $set_data);


2. $set_data contains
Code:

Array
(
    [facebook] => https://facebook.com/ <---- this will be removed i
    [instagram] => https://instagram.com/
    [twitter] => https://twitter.com/
)


4. code in html

Code:

    {$_setData.facebook}



5. I receive an error

Code:

Severity: Notice
Message: Undefined index: facebook
Filename: templates_c/5125124f1e59f2258a491707dcd0a86cf434db62_0.file.home_template.html.php
Line Number: 94
Backtrace:.......


5.I am aware that there is no facebook in the array but I wanted to adjust the error that if the variable (ex. facebook) is not defined in the controller the smarty code (ex. {$_setData.facebook}) will just display null/empty/0.

How can I make this happen in smarty? Is this possible to adjust the smarty?

Let me know if you have question or clarifications to my post.
Thanks in advance! Smile
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 04, 2016 6:12 pm    Post subject: Reply with quote

Smarty is not a programming language. I'm failing to see how is this question related to Smarty in any way.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue May 10, 2016 6:24 am    Post subject: Reply with quote

Use the 'default' modifier

Code:
 {$_setData.facebook|default}


http://www.smarty.net/docs/en/language.modifier.default.tpl
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