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.
问题:
回答1:
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.
[EDIT]
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>
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.
回答2:
The body tag of a category page should have a class name that is equal to "category-" + category name of that current page.
回答3:
here is the simple solution with free extention http://www.magentocommerce.com/magento-connect/multi-flat-shipping.html