CMSMadeSimple升级到Smarty Templating - 意外属性

时间:2013-11-20 18:01:42

标签: upgrade smarty3 cmsmadesimple

我是CMSMS的新手,并通过痛苦的升级路径进行旧版安装,以使其达到当前版本。其中一个主要变化涉及使用Smarty 3作为它的模板引擎。此更改已破坏了一些现有模板。

相关的CMSMS模块称为“产品和库存管理器”,它看起来像是“Calguys Module Extensions”的一部分

以下是我收到的错误消息:

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

这是投掷它的整个模板:

 {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}

以下是发生错误的模板的相关片段:

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

据我所知,我们正在调用一个自定义函数,其名称基于我们在数据库中的产品。我们发送一个它没有预料到的属性“父”。如果我删除该属性,则错误消失但输出变得奇怪。

没有灵丹妙药我认为任何寻找这个功能的线索都会对我有所帮助。我对使用似乎是ltrim(“ - 1”)的东西感到困惑,所以对此的任何解释都会很好。也许我可以用更长的if块替换这一行来纠正函数调用?

编辑 - 以下是变量的一些示例值:

$ products_path_names。$ key包含字符串'Granite'

$ tmp持有字符串00017

谢谢!

1 个答案:

答案 0 :(得分:0)

我或多或少地解决了它。我完全摆脱了父属性,并通过改变这一行来修复奇怪的输出:

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

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

它没有将空字符串计为false。

似乎现在正在工作。