Question

I'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's templating engine. This change has broken a couple of the existing templates.

The related CMSMS module is called "Product and Inventory Manager" which looks like it's part of "Calguys Module Extensions"

Here's the error message I'm getting:

Syntax Error in template "module_db_tpl:ProductsWithLocation;summary_default"  on line 26 "<h2 style="float:left;margin-right:10px;color:"#fff">{$products_path_names.$key parent=$tmp|ltrim:'-1'}</h2>" unexpected "parent" attribute

Here's the entire template that's throwing it:

 {if !isset($items)}
  {cgerror}<h2>Sorry! There is No material matched the query</h2>{/cgerror}
<p>Please try browsing our <a href="metarial-index">"full catalog" </a>here. </p>
{else}



{if empty($products_path_names)}


{assign var='products_pagelimit' value=$actionparams.pagelimit|default:'25'}
{assign var='products_parent' value=$actionparams.hierarchyid|default:$actionparams.parent}
{assign var='products_hier_info' value=$ProductsWithLocation->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) }<div style="overflow:hidden">
 <h2 style="float:left;margin-right:10px">Browsing </h2>
{foreach from=$products_path_ids  key='key' item='tmp' }
 {if !$smarty.foreach.default.last}
{module_action_link module='ProductsWithLocation' action='hierarchy' text=$products_path_names.$key page=$page_alias parent=$tmp|ltrim:'0' pagelimit=$products_pagelimit}

{else}

 <h2 style="float:left;margin-right:10px;color:"#fff">{$products_path_names.$key parent=$tmp|ltrim:'-1'}</h2>

{/if}




{/foreach}<h2 style="float:left"> Colors...</h2></div>

{/if}


{/if}


<div id="status-bar"

{if isset($pagecount) && $pagecount gt 1}
<span class="page-text">{$curpage} {$oftext} {$pagecount} {$pagetext} </span>
<ul  class="paging">
<li>{$firstlink}</li><li>{$prevlink}</li> <li>{$nextlink}</li><li>{$lastlink}</li></ul>
{/if}

<a href="#" class="switch_thumb">Switch Thumb</a>

{if $products_parent !=13 }

<a  class="a-z" href="{$products_path_names.$key}_Index.htm">{$products_path_names.$key}</a>
{else}

 {/if}



</div>

<ul class="gallery">

{foreach from=$items item=entry}


   {* 
     the summary template has access to custom fields via the $entry->fields hash
     and to categories via the $entry->categories array of objects.  Also
     attribute information is available via $entry->attributes.
     you should use the get_template_vars and the print_r modifier to see
     what is available
    *}

    {if $products_parent == 13 }

  <li>




     <dl>
  <dt><a class="tip_trigger more-stone-info"  href="{$entry->detail_url}">{$entry->product_name}<span class="tip">More information about  <strong style="color:#9BD8EB">{$entry->product_name}</strong></span></a></dt> 
{* accessing all of the fields in a list *}
{if isset($entry->fields)}

  {foreach from=$entry->fields key='name' item='field'}
     {if isset($field->value)}
      {if  $field->type == 'checkbox' or $field->type == 'image' && isset($field->thumbnail)}
     {else} 


{/if}


 {if $field->type == 'image' && isset($field->thumbnail)}
<a  href="{$entry->detail_url}"  class="tip_trigger thumb product_pre"><span class="tip">More information about  <strong style="color:#9BD8EB">{$entry->product_name}</strong></span><img src="{$entry->file_location}/{$field->thumbnail}" alt="{$field->value}"/></a>
{/if}
     {/if}
  {/foreach}
{/if}
{assign var='hinfo' value=$ProductsWithLocation->GetHierarchyInfo($entry->hierarchy_id)}

<dd><em>Stone Type: </em>Cambria Quartz</dd>
<dd><em>Collection: </em>{module_action_link module=ProductsWithLocation action=default  hierarchyid=$entry->hierarchy_id text=$hinfo.name}</dd>

</dl>


  </li>


{else}

<li>




     <dl>
  <dt><a class="tip_trigger more-stone-info"  href="{$entry->detail_url}">{$entry->product_name}<span class="tip">More information about  <strong style="color:#9BD8EB">{$entry->product_name}</strong></span></a></dt> 
{* accessing all of the fields in a list *}
{if isset($entry->fields)}

  {foreach from=$entry->fields key='name' item='field'}
     {if isset($field->value) && $field->name != 'GalleryFolder'}
      {if  $field->type == 'checkbox' or $field->type == 'image' && isset($field->thumbnail)}
     {else} 
 <dd><em>
 {$name} 
</em>

       {if is_array($field->value)}
         {if !empty($field->value) }

         {foreach from=$field->value item='val'}
          {if $field->type == 'image' && isset($field->thumbnail)}
         {else}

           {module_action_link module=$mod->GetName() action=default fieldid=$field->id fieldval=$val text=$val} {/if}
         {/foreach}
         {/if}
       {else}
{if $field->type == 'image' && isset($field->thumbnail)}
         {else}
        {module_action_link module=$mod->GetName() action=default fieldid=$field->id fieldval=$field->value text=$field->value}   {/if}
       {/if}

 </dd> 

{/if}


 {if $field->type == 'image' && isset($field->thumbnail)}
<a  href="{$entry->detail_url}"  class="tip_trigger thumb product_pre"><span class="tip">More information about  <strong style="color:#9BD8EB">{$entry->product_name}</strong></span><img src="{$entry->file_location}/{$field->thumbnail}" alt="{$field->value}"/></a>
{/if}
     {/if}
  {/foreach}
{/if}
{assign var='hinfo' value=$ProductsWithLocation->GetHierarchyInfo($entry->hierarchy_id)}
<dd><em>Stone Type: </em>{module_action_link module=ProductsWithLocation action=default  hierarchyid=$entry->hierarchy_id text=$hinfo.name}</dd>

</dl>


  </li>

{/if}


{/foreach}
</ul>{/if}

Here's the relevant snip of that template where the error occurs:

{$products_path_names.$key parent=$tmp|ltrim:'-1'}</h2>

From what I understand we're calling a custom function with a name based on products we have in our database. We're sending it an attribute "parent" which it's not expecting. If I remove that attribute the error goes away but the output gets weird.

Short of a magic bullet I think any clues where to look for this function being defined would help me. I'm also baffled by the use of what appears to be ltrim("-1") 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?

Edit - Here's some sample values for the variables:

$products_path_names.$key holds string 'Granite'

$tmp holds string 00017

Thanks!

Was it helpful?

Solution

I more or less solved it. I got rid of the parent attribute entirely and fixed the weird output by changing this line:

{if !$smarty.foreach.default.last}

to

{if $smarty.foreach.default.last != ''}

It was not counting an empty string as false.

Seems to work now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top