{"id":7179,"date":"2014-05-27T08:58:38","date_gmt":"2014-05-27T08:58:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/cmsmadesimple-upgrade-to-smarty-templating-unexpected-attribute-collection-of-common-programming-errors\/"},"modified":"2014-05-27T08:58:38","modified_gmt":"2014-05-27T08:58:38","slug":"cmsmadesimple-upgrade-to-smarty-templating-unexpected-attribute-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/cmsmadesimple-upgrade-to-smarty-templating-unexpected-attribute-collection-of-common-programming-errors\/","title":{"rendered":"CMSMadeSimple upgrade to Smarty Templating &#8211; unexpected attribute-Collection of common programming errors"},"content":{"rendered":"<p>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.<\/p>\n<p>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;<\/p>\n<p>Here&#8217;s the error message I&#8217;m getting:<\/p>\n<pre><code>Syntax Error in template \"module_db_tpl:ProductsWithLocation;summary_default\"  on line 26 \"<\/code><\/pre>\n<h2 style=\"float:left;margin-right:10px;color:\" parent=\"$tmp|ltrim:'-1'}\/h2&quot;\" unexpected=\"parent&quot;\" attribute=\"\" entire=\"\" template=\"\" throwing=\"\" precode=\"\" there=\"\" is=\"\" no=\"\" material=\"\" matched=\"\" the=\"\" pplease=\"\" try=\"\" browsing=\"\" our=\"\" a=\"\" href=\"metarial-index\" full=\"\" var='products_hier_info' value=\"$ProductsWithLocation-\"><code>GetHierarchyInfo($products_parent)} {assign var='products_path_ids' value='.'|explode:$products_hier_info.hierarchy} {assign var='products_path_names' value=' | '|explode:$products_hier_info.long_name} {if !empty($products_parent) }<\/code><\/h2>\n<pre> Browsing \n{foreach from=$products_path_ids  key='key' item='tmp' }\n {if !$smarty.foreach.default.last}\n{module_action_link module='ProductsWithLocation' action='hierarchy' text=$products_path_names.$key page=$page_alias parent=$tmp|ltrim:'0' pagelimit=$products_pagelimit}\n\n{else}\n\n <\/pre>\n<h2 style=\"float:left;margin-right:10px;color:; float:left\" parent=\"$tmp|ltrim:'-1'}\/h2\" div=\"\" id=\"status-bar\" gt=\"\" span=\"\" switch=\"\" a=\"\" ul=\"\" from=\"$items\" item=\"entry}\" summary=\"\" template=\"\" has=\"\" access=\"\" custom=\"\" fields=\"\" hash=\"\" categories=\"\" array=\"\" of=\"\" objects.=\"\" also=\"\" attribute=\"\" information=\"\" via=\"\" you=\"\" should=\"\" use=\"\" get_template_vars=\"\" and=\"\" the=\"\" print_r=\"\" modifier=\"\" to=\"\" see=\"\" what=\"\" is=\"\" available=\"\" li=\"\" dl=\"\" dta=\"\" class=\"tip_trigger more-stone-info\" href=\"{$entry-%3Edetail_url}\"><code>{$entry-&gt;product_name}More information about <strong style=\"color:#9BD8EB\">{$entry-&gt;product_name}<\/strong> {* accessing all of the fields in a list *} {if isset($entry-&gt;fields)} {foreach from=$entry-&gt;fields key='name' item='field'} {if isset($field-&gt;value)} {if $field-&gt;type == 'checkbox' or $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} {else} {\/if} {if $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} More information about <strong style=\"color:#9BD8EB\">{$entry-&gt;product_name}<\/strong><img decoding=\"async\" src=\"{$entry-file_location}\/{$field-thumbnail}\" alt=\"{$field-value}\" \/> {\/if} {\/if} {\/foreach} {\/if} {assign var='hinfo' value=$ProductsWithLocation-&gt;GetHierarchyInfo($entry-&gt;hierarchy_id)} <em>Stone Type:<\/em> Cambria Quartz <em>Collection:<\/em> {module_action_link module=ProductsWithLocation action=default hierarchyid=$entry-&gt;hierarchy_id text=$hinfo.name} {else}<\/code><\/h2>\n<li><code>{$entry-&gt;product_name}More information about <strong style=\"color:#9BD8EB\">{$entry-&gt;product_name}<\/strong> {* accessing all of the fields in a list *} {if isset($entry-&gt;fields)} {foreach from=$entry-&gt;fields key='name' item='field'} {if isset($field-&gt;value) &amp;&amp; $field-&gt;name != 'GalleryFolder'} {if $field-&gt;type == 'checkbox' or $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} {else} <em>{$name}<\/em> {if is_array($field-&gt;value)} {if !empty($field-&gt;value) } {foreach from=$field-&gt;value item='val'} {if $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} {else} {module_action_link module=$mod-&gt;GetName() action=default fieldid=$field-&gt;id fieldval=$val text=$val} {\/if} {\/foreach} {\/if} {else} {if $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} {else} {module_action_link module=$mod-&gt;GetName() action=default fieldid=$field-&gt;id fieldval=$field-&gt;value text=$field-&gt;value} {\/if} {\/if} {\/if} {if $field-&gt;type == 'image' &amp;&amp; isset($field-&gt;thumbnail)} More information about <strong style=\"color:#9BD8EB\">{$entry-&gt;product_name}<\/strong><img decoding=\"async\" src=\"{$entry-file_location}\/{$field-thumbnail}\" alt=\"{$field-value}\" \/> {\/if} {\/if} {\/foreach} {\/if} {assign var='hinfo' value=$ProductsWithLocation-&gt;GetHierarchyInfo($entry-&gt;hierarchy_id)} <em>Stone Type:<\/em> {module_action_link module=ProductsWithLocation action=default hierarchyid=$entry-&gt;hierarchy_id text=$hinfo.name}<\/code><\/li>\n<pre> \n\n{\/if}\n\n\n{\/foreach}\n{\/if}\n<\/pre>\n<p><code>Here's the relevant snip of that template where the error occurs:<\/code><\/p>\n<pre><code><code>{$products_path_names.$key parent=$tmp|ltrim:'-1'}\n<\/code><\/code><\/pre>\n<p>From what I understand we&#8217;re calling a custom function with a name based on products we have in our database. We&#8217;re sending it an attribute &#8220;parent&#8221; which it&#8217;s not expecting. If I remove that attribute the error goes away but the output gets weird.<\/p>\n<p>Short of a magic bullet I think any clues where to look for this function being defined would help me. I&#8217;m also baffled by the use of what appears to be ltrim(&#8220;-1&#8221;) so any explanation of that would also be nice. Maybe I can replace this line with a longer if block to correct the function call?<\/p>\n<p>Edit &#8211; Here&#8217;s some sample values for the variables:<\/p>\n<p>$products_path_names.$key holds string &#8216;Granite&#8217;<\/p>\n<p>$tmp holds string 00017<\/p>\n<p>Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 and Inventory Manager&#8221; which [&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],"tags":[],"class_list":["post-7179","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7179","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=7179"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7179\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}