{"id":7143,"date":"2014-05-25T22:52:28","date_gmt":"2014-05-25T22:52:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/25\/problem-about-smarty3-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:47:12","modified_gmt":"2022-08-30T15:47:12","slug":"problem-about-smarty3-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/25\/problem-about-smarty3-collection-of-common-programming-errors\/","title":{"rendered":"problem about smarty3-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/83a5bc139910572dc4d618fd6f4758ff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSyntax Error<br \/>\nupgrade smarty3 cmsmadesimple<br \/>\nI&#8217;m new to CMSMS and taking an older installation through a painful upgrade path to get it to the current version. One of the major changes involves using Smarty 3 for it&#8217;s templating engine. This change has broken a couple of the existing templates.The related CMSMS module is called &#8220;Product and Inventory Manager&#8221; which looks like it&#8217;s part of &#8220;Calguys Module Extensions&#8221;Here&#8217;s the error message I&#8217;m getting:Syntax Error in template &#8220;module_db_tpl:ProductsWithLocation;summary_default&#8221; on line 26<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4fb133b33b847eef48644c7e00dde72c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDainis Abols<br \/>\nphp exception-handling smarty smarty3<br \/>\nI have block try &#8211; catch and i want assign error to the template to $error. I tried:catch (Exception $e) {$smarty-&gt;assign(&#8220;error&#8221;, &#8216;Error! Details: &#8216;.$e-&gt;getMessage()); }Also tried:catch (Exception $e) {$error = $e-&gt;getMessage()); } $smarty-&gt;assign(&#8220;error&#8221;, $error);But when there is no error, smarty requires this variable and all crashes. Is there any way to deal with it without using if? Or may be i am doing wrong from the begining?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/574a32b2bc2c7c0c9a0466a6f2689862?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAthanatos<br \/>\nphp smarty smarty3<br \/>\nMy ajax php located in maindirexample\/actions is calling a tpl file one folder up in maindirexample\/templatesfetch(&#8216;..\/templates\/popupMyItems.tpl&#8217;); However this throws an error &lt;br \/&gt; &lt;b&gt;Fatal error&lt;\/b&gt;: Uncaught exception &#8216;SmartyException&#8217; with message &#8216;Unable to load template file &#8216;list-myItems.tpl&#8217; in &#8216;..\/templates\/popupMyItems.tpl&#8217;popupMyitems.tpl seems to be called ok, however list-myItems.tpl fails (this is included in popupMyitems.tpl) ..{foreachfrom=$uniquecategories i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/Rj5b5.jpg?s=32&amp;g=1\" \/><br \/>\nVipan Kumar<br \/>\nphp smarty3 server-configuration<br \/>\nI have created project in smarty and now i am trying to host it on pagodabox.com. I have created application on pagodabox.com and uploaded all code on to this application but problem is this now i am unable to configure cache and compiler directory in pagodabox.com that&#8217;s why it output fetal error because cache and compiler directory is read only mode. I have try Boxfile to resolve this issue but failing to solve. I am not aware how i can make these directory writable. please help me. this is ur<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/df8f1c2a3adda939fdbc04d7f8140faa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nfl3x7<br \/>\nphp codeigniter smarty codeigniter-2 smarty3<br \/>\nIm currently using codeigniter 2 with ci-Smarty. Just been trying to add a smarty output filter but not having much luck. Its as if the function cannot be found or something?I am using a plugin as the output filter function and have the following code:LOCATION: \/libraries\/Smarty.php\/\/ Set email output filter $this-&gt;loadFilter(&#8216;output&#8217;, &#8216;protect_email&#8217;);LOCATION: \/third_party\/Smarty\/plugins\/function.protect_email.phpfunction smarty_function_protect_email($tpl_output, Smarty_Internal_Template $<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/F4W2b.jpg?s=32&amp;g=1\" \/><br \/>\nHailwood<br \/>\nphp javascript escaping smarty3<br \/>\nI am using the below code with smarty V3&lt;script&gt;$(function() {jwplayer(&#8220;video-player-{$v-&gt;id}&#8221;).setup( {file: &#8220;\/webfiles\/competitions\/movies\/{$v-&gt;file}&#8221;,skin: &#8220;\/assets\/jwplayer\/skins\/simplicity\/simplicity.zip&#8221;,width: 446,height: 353,stretching: &#8220;fill&#8221;,flashplayer: &#8220;\/assets\/jwplayer\/player.swf&#8221;} );} ); &lt;\/script&gt;The manual states:Note{literal}{\/literal} tags are normally not necessary, as Smartyignores delimiters that are surrounded by whitespace. Be sure yourjavascript and CSS c<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d05a145b7625208633fb1707df2b9b6a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJochenJung<br \/>\ninclude smarty block smarty3<br \/>\nI have some templates written with Smarty 3:A layout page An index page An include pagelayout.tpl:{block &#8220;css&#8221;}{\/block} {block &#8220;js&#8221;}{\/block} {block &#8220;content&#8221;}{\/block}index.tpl:{extends &#8220;layout.tpl&#8221;} {block &#8220;content&#8221;} content text {include &#8220;include.tpl&#8221;} {\/block}include.tpl{block &#8220;js&#8221; append} include some extra js files for this included content {\/block} include textBut I got a compiler exception:Fatal error: Uncaught exception &#8216;SmartyCompilerException&#8217; with message &#8216;Syntax Error in template inc<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9957cfe26be1f789e5b810060ad6ae81?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlukaswilkeer<br \/>\nsmarty3<br \/>\nWhat&#8217;s this? Does any error in the configuration file? Following is the full error.Fatal error: Uncaught exception &#8216;SmartyException&#8217; with message &#8216;Unableto load template file &#8216;index.tpl&#8221; in\/var\/www\/stoke\/libs\/sysplugins\/smarty_internal_templatebase.php:127Stack trace: #0\/var\/www\/stoke\/libs\/sysplugins\/smarty_internal_templatebase.php(374):Smarty_Internal_TemplateBase-&gt;fetch(&#8216;index.tpl&#8217;, NULL, NULL, NULL,true) #1 \/var\/www\/stoke\/index.php(41):Smarty_Internal_TemplateBase-&gt;display(&#8216;index.tpl&#8217;) #2 {<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7f6b4f4915711d77a68aa9a4a2604cd0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRajat<br \/>\nphp smarty smarty3<br \/>\nMy file structure:&#8211;header.php &#8211;smarty&#8211;templates&#8211; x.tpl&#8211;cache&#8211;configs&#8211;templates_c &#8211;articles&#8211; testPage.phpCode in header.php$smarty = new Smarty();$smarty-&gt;setTemplateDir(&#8216;smarty\/templates&#8217;); $smarty-&gt;setCompileDir(&#8216;smarty\/templates_c&#8217;); $smarty-&gt;setCacheDir(&#8216;smarty\/cache&#8217;); $smarty-&gt;setConfigDir(&#8216;smarty\/configs&#8217;);Code in testPage.php&lt;?phpinclude(&#8216;..\/header.php&#8217;);$smarty-&gt;display(&#8216;x.tpl&#8217;); ?&gt;I am hitting this error:PHP Fatal error: Uncaught exception &#8216;SmartyException<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e0d73436861c9b54bbf2a5ec26c8ac76?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser861587<br \/>\nphp smarty echo combine smarty3<br \/>\nWhy doesn&#8217;t this work in Smarty?{my_function($test.&#8217;a1&#8242;)}It&#8217;s showing following error: Fatal error: Uncaught exception &#8216;SmartyCompilerException&#8217; with message &#8216;Syntax Error in template &#8220;test.tpl&#8221; on line 1 &#8220;{my_function($test.&#8217;a1&#8217;)}&#8221; Unexpected &#8220;&#8216;a1&#8242;&#8221;, expected one of: &#8220;{&#8221; , &#8220;$&#8221; , &#8220;identifier&#8221; , INTEGER&#8217; in&#8230;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/503db877725f86601b15c021b221f2e0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nr4.<br \/>\nkohana smarty kohana-3 smarty3<br \/>\nI&#8217;m learning Kohana 3.2.0 together with KSmarty for Kohana 3. I&#8217;d like to write an anchor on the page like this:&lt;a href=&#8221;http:\/\/www.mysite.cz\/page\/list&#8221;&gt;Page list&lt;\/a&gt;I can build the url in the controller and pass it to Smarty as a variable but. Is there a way to build the anchor or URL in Smarty template (including &#8220;http:\/\/www.mysite.cz&#8221; part)?If it is not possible to build the anchor. Is it at least possible to build full URL?The Reason: I have a main template which includes another<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aee34ebdb4f8efaf6ddf16716343f301?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkyyych<br \/>\nzend-framework smarty3<br \/>\nhttps:\/\/github.com\/Domi-cc\/SmartyModule thank you for the above module, I have integrated smarty3 into zend2 ,but i dont&#8217;t know how to pass vars to smarty,here is my application structure? config\/ ? data\/ ? module\/? Application\/? config\/? language\/? src\/? Application\/? Controller\/IndexController.php*? view\/? application\/? index\/index.tpl*? error\/? layout\/Module.php*? SmartyModule\/ ? public\/ ? vendor\/init_autoloader.php*i made up some code in module\/Application\/src\/Application\/Controller\/IndexCon<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/89841cf57849bbe957c155d3d68252f6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJason<br \/>\nphp smarty3<br \/>\nI can&#8217;t seem to find a way to escape the &#8220;@&#8221; sign in a smarty variable output block. Here&#8217;s my setup:$data = array(&#8220;myvar@display&#8221;=&gt;4534534); $smarty-&gt;assign($data); Assign doco hereIn my template file:&lt;body&gt;{$myvar@display} &lt;\/body&gt;Output:Message: Undefined property: Smarty_Variable::$displayAny ideas how I can display that without changing the &#8220;@&#8221; sign (I am unable to modify this as it is a convention used throughout the application and I do not have control over this)Running<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4d8154b3f9ba6f4190483c5231d577d3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nken<br \/>\nphp smarty smarty3<br \/>\nI have a smarty template that has been working fine for me for some time but for reasons I don&#8217;t quite understand one of the variables that I &#8220;assign&#8221; to the template is $activity_date and when I send in time information with my date information it has some surprising effects (aka, it works when &#8220;2012-12-27&#8221; is passed in but falls over in a bizzare way when &#8220;2012-12-27 00:00:00&#8221; is passed in. It might make a little more sense if the problems actually were related to some sort of template interac<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d45bcddf7427555959fe144a9ca80977?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngrisevg<br \/>\nsmarty smarty3<br \/>\nIs there a way to force Smarty 3 throw exceptions instead of notices? I want application to crash in there is undefined variable. In smarty 2 there was error_unassigned param, but looks like it&#8217;s removed in v3.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/574a32b2bc2c7c0c9a0466a6f2689862?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAthanatos<br \/>\nsmarty smarty3<br \/>\nIn my PHP file Using $smarty-&gt;config_load(&#8216;en.conf&#8217;);I am getting the following :Notice: function call &#8216;config_load&#8217; is unknown or deprecated. in C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htdocs\\ex\\libs\\sysplugins\\smarty_internal_wrapper.php on line 57I am then changing the statement to @$smarty-&gt;config_load(&#8216;en.conf&#8217;); and the error is hidden.However all my ajax scripts are failing at this point and in the ajax response using firebug, I can see a fatal error this time :<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4d8154b3f9ba6f4190483c5231d577d3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nken<br \/>\nsmarty smarty3<br \/>\nI am trying to step a bit beyond the basic usage of Smarty and ran into a small problem using the default &#8220;capitalize&#8221; modifier. I am operating with the assumption that no explicit calls need to be made to use this operator so in my template I have the following:{* Smarty Part: Add-ins *}&lt;div class=&#8221;control-group form-inline&#8221;&gt; &lt;label class=&#8221;control-label&#8221;&gt;Add-ins:&lt;\/label&gt;&lt;div class=&#8221;controls &#8220;&gt;{foreach $add_ins as $add_in}&lt;label class=&#8221;checkbox inline&#8221;&gt;&lt;input typ<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e9a534c767e52e8d8348b6a16e3abb93?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMihai Iorga<br \/>\nphp smarty smarty3<br \/>\nSo I have an old website which uses an older version of smarty, as today I wanted to upgrade to latest version, and it hit&#8217;s me with an error:[Fri Aug 19 11:21:19 2011] [error] [client ***.***.***.***] PHP Notice: Undefined property: Smarty::$allow_php_tag in \/work\/smarty3.1rc1\/Smarty.class.php on line 592 [Fri Aug 19 11:21:19 2011] [error] [client ***.***.***.***] PHP Fatal error: Uncaught exception &#8216;SmartyCompilerException&#8217; with message &#8216;Syntax Error in template &#8220;\/work\/templates\/modules\/main<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3df2379fc0221bb0281c0d608542bd84?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nVerbeia<br \/>\nphp codeigniter smarty eval smarty3<br \/>\nI am trying to use one of CodeIgniter functions with smarty which the variable name is Dynamic. normally the function is called like this : {set_value(aaa, $f_aaa} &lt;br&gt;but in my code aaa is replaced with a dynamic value first part is easy : {set_value($row-&gt;Field, $f_aaa} &lt;br&gt;but I don&#8217;t know how to use eval in smarty for this situation .it should call the function with a loop (ex with following input\/variable){set_value(name, $f_name} {set_value(address, $f_address} edit: I forgo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c204475ee30b9a371607bc6adac67b3c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmspir<br \/>\nphp smarty smarty3<br \/>\nI have the following code, that works for smarty 2.x {assign var=somename value=jsFunction($frontItemKey);}but smarty v3 throws an error:unknown function &#8220;jsFunction&#8221;How can I fix this?Thanks!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/67a9f022dde0b87cd3a8e1e3ead8dec5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nair4x<br \/>\nphp smarty smarty3 cmsmadesimple<br \/>\nHopefully someone can help me with this. I am using smarty within CMSMS and have something called a User Defined Tag running within my page. This contains the following code: $db = cmsms()-&gt;GetDb(); $menu = $smarty-&gt;get_template_vars(&#8216;page&#8217;); $user_id = $smarty-&gt;get_template_vars(&#8216;userid&#8217;); if (!isset($user_id)) { $user_id = -1; } \/\/ Getting menu items from DB $query = &#8216;SELECT * FROM &#8216;. cms_db_prefix() .&#8217;module_tools_options WHERE active = 1 AND user_id = ? AND menu = ? ORDER BY so<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0b389feb94f05b7fc73b422c6d24981e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPaul DelRe<br \/>\nsmarty smarty3<br \/>\ncurrently i change smarty 2 -&gt; version 3but after i change got problem as below.SmartyCompilerException: Syntax Error in template &#8220;\/home\/test\/engine\/mobile9\/template\/t_footer.tpl&#8221; on line 28 &#8220;{php}&#8221; unknown tag &#8220;php&#8221; in \/home\/test\/engine\/modules\/smarty\/sysplugins\/smarty_internal_templatecompilerbase.php on line 617after that i check smarty 3 documentations. it shown {php} is valid operator.<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n<p>I discovery a place to host code\u3001demo\u3001 blog and websites.<br \/>\nSite access is fast but not money<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.m5zn.com\/newuploads\/2014\/01\/30\/jpg\/e7da807964b1fff.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax Error upgrade smarty3 cmsmadesimple I&#8217;m new to CMSMS and taking an older installation through a painful upgrade path to get it to the current version. One of the major changes involves using Smarty 3 for it&#8217;s templating engine. This change has broken a couple of the existing templates.The related CMSMS module is called &#8220;Product [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,8],"tags":[],"class_list":["post-7143","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-zend-framework"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7143"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7143\/revisions"}],"predecessor-version":[{"id":8920,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7143\/revisions\/8920"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}