如何更改magento中某一类别的背景图像? [英] How to change the background image of one category in magento?
问题描述
我想更改magento中一个类别页面的背景.我是从CSS做到的,但是它正在申请magento中的所有页面.我只想更改一个类别页面背景.
I want to change the background of one category page in magento. i did it from css but it is applying for all the pages in magento. i want to change only one category page background.
推荐答案
您可以从css文件中执行此操作,但是您必须小心使用的类.对于每个页面,Magento都会向body
元素添加一个或多个类.您可以使用它.
所有类别页面的正文类别为catalog_category_view
.如果要更改所有类别的内容,这很有用,但是也有类别特定的类别.
以该页面为例:它具有类categorypath-apparel-shoes category-shoes
.因此,您可以使用从完整类别路径构建的categorypath-apparel-shoes
或从类别的url键生成的category-shoes
.
另一种方法是仅包括针对该特定类别的css文件. Magento为每个类别提供布局手柄.假设您的类别的ID为8.您可以将其添加到布局文件中:
You can do it from the css file, but you have to be careful what class you use. For each page Magento adds one or more classes to the body
element. You can use that.
All category pages have the body class catalog_category_view
. This is useful if you want to change something for all the categories, but there are also category specific classes.
take this page for example: It has the classes categorypath-apparel-shoes category-shoes
. So you can use either categorypath-apparel-shoes
that is built from the full category path, or category-shoes
that is generated from the url key of the category.
An other approach would be to include a css file just for that specific category. Magento offers layout handles for each category. Let's say that your category has the id 8. You can add this in your layout file:
<CATEGORY_8>
<reference name="head">
<action method="addCss"><stylesheet>css/category8.css</stylesheet></action>
</reference>
</CATEGORY_8>
现在创建文件skin/frontend/{interface}/{theme}/css/category8.css
并在其中添加魔术.只会为您的特定类别加载它.
now create the file skin/frontend/{interface}/{theme}/css/category8.css
and add your magic in there. It will only be loaded for your specific category.
这篇关于如何更改magento中某一类别的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!