我是 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 包含字符串“Granite”
$tmp 保存字符串 00017
谢谢!