我是CMSMS的新手,通过一个痛苦的升级路径来进行旧的安装,从而将其升级到当前版本。其中一个主要的改变是使用Smarty 3作为模板引擎。此更改破坏了现有的几个模板。
相关的CMSMS模块称为“产品和库存管理器”,它看起来像是"Calguys模块扩展“的一部分。
下面是我收到的错误消息:
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持有“花岗岩”字符串
$tmp持有字符串00017
谢谢!
发布于 2013-11-20 20:12:14
我差不多解决了。我完全消除了父属性,并通过更改以下行修复了奇怪的输出:
{if !$smarty.foreach.default.last}至
{if $smarty.foreach.default.last != ''}它没有将空字符串计算为false。
现在似乎起作用了。
https://stackoverflow.com/questions/20103469
复制相似问题