在类别页面上的CS-cart中,如果已上传,则会获得带有图像的子类别列表。
我如何获得在主菜单(topmenu_dropdown.tpl)中也显示的类别图像?
我尝试使用以下内容:
{include file="common/image.tpl" images=$item2.main_pair image_width=150}
,但看起来图像没有可用于topmenu_dropdown.tpl
终于找到了答案,因此将发布可能需要它的其他人。
这是可以使用非常有用的fn_get_category_data
的,它使您能够从类别获取数据。
在topmenu_dropdown.tpl
中,您首先需要查找类别ID。虽然这不是直接可用的,但您可以将其从href
变量的末端删除。(仅当它是自动生成的类别菜单时,这才有可能)
{assign var=catid value="="|explode:$item2.href}
这将通过在=标志的HREF分配HREF来形成数组。
{$category_data = $catid.1|fn_get_category_data}
然后,您可以使用ID号来获取正确的类别数据。
现在$category_data
将拥有您想要的所有变量,包括使用$category_data.main_pair
最后,我有了一个新想法来显示菜单中的类别图像。
,更感谢从
获得类别ID$ item2对象
如菜单中的CS-Cart类别图像所示
{assign var=catid value="="|explode:$item2.href}
{assign var="cat_image" value=$catid.1|fn_get_image_pairs:'category':'M':true:true}
{if $cat_image.pair_id}
<div class="categories-image">
{include file="common/image.tpl" images=$cat_image.detailed image_width=150}
</div>
{/if}