我想在顶部导航菜单的名称(即类别名称)旁边显示一个小图像。
所以我想要类似的东西
Category1Name small_img | Category2Name small_img2 | Category3Name small_img3
干杯
编辑:这是使用 FIREBUG 作为我的第一个类别名称的 d HTML 代码
<div class="nav-container">
<ul id="nav">
<li class="level0 nav-1 level-top first parent">
<a class="level-top" href="http://localhost:8888/devats/index.php/ribbons-for-craft.html">
<span>RIBBONS FOR CRAFT</span>
<li class="level0 nav-2 level-top parent">
<a class="level-top" href="http://localhost:8888/devats/index.php/ribbons-for-decoration.html">
<span>RIBBONS FOR DECORATION</span>
.
.
.
n so on for my rest of the categories.
最佳答案
您可以将类别 ID 添加到类中,然后通过 css 修改此类。
在 app/code/local/Artlantis/Catalog/Block 下创建一个文件夹(Artlantis 是命名空间,替换为你的)并将 app/code/core/Mage/Catalog/Block 中的 Navigation.php 放入新创建的文件夹中。
如下更改 Navigation.php :
之前:
# find _renderCategoryMenuItemHtml method
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
之后:
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span class="category_'.$this->getCurrentCategory()->getId().'">'.$this->escapeHtml($category->getName()).'</span>';
$html[] = '</a>';
在/app/etc/modules文件夹中添加Artlantis_Catalog.xml
<?xml version="1.0"?>
<config>
<modules>
<Artlantis_Catalog>
<active>true</active>
<codePool>local</codePool>
</Artlantis_Catalog>
</modules>
</config>
在styles.css中添加class,比如你的目录id为5(当然你应该修改css)
.category_5 {
background: url(../images/category_5_icon.png) no-repeat transparent;
}
PS:如有任何问题,请发布 Firebug 的 HTML 输出,而不是默认代码,修改后的输出。
关于php - Magento - 顶部类别名称旁边的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9235068/