I want to hide some things from certain product list (catalogue) pages - I know when using Wordpress you can use the page ID's etc but is there any way in Magento to target just certain product list pages?
Just to be clear, I am on about the page that lists all of the products from certain categories - not CMS pages.
In my head it makes sense that I can simply target by a URL?!? E.g. in the head if url = ...
Thought that is a complete guess.
The main aim is to hide the prices and buy buttons of products on all pages except from two categories - there might be an easier way to do it?
You can do this within the category settings:
Magento Admin -> Catalog -> Manage Categories -> Custom Design -> Custom Layout Update
This section takes XML updates, and you can add CSS to your head via XML here, like so (choose one):
//Simple way for CSS - Falls Back from Your Theme to Default/Base
//Goes to your theme's skin folder first
<reference name="head">
<action method="addCss"><name>css/yourStylesheet.css</name></action>
</reference>
//Specific way for CSS, can also be used for JS
//More lines, but you can change the type for different folders and javascript too
<reference name="head">
<action method="addItem">
<type>skin_css</type>
<name>css/yourStylesheet.css</name>
</action>
</reference>
Save and refresh your cache. Make sure your stylesheets are in the right folders!
addItem Types<type>skin_css</type>
=> Magento/skin/frontend/your_package/your_theme/
Folder<type>skin_js</type>
=> Same as above, specify folder js/yourScript.js
for name.<type>js</type>
=> Looks in the root Magento Installation Folder. Used for the "\js\" and "\lib\" folders in the root directory of a magento install, commonly. I suppose you could tree it out to different folders if you'd like, since the base magento directory is the working directory with this type.
Each page has a different class (classes) on the body
element. One of the classes on the body
element is the layout handle of the page (with -
instead of _
). The other classes may vary depending on the page type.
For example, a category page will have the following classes on the body
.
catalog-category-view
- derived from the layout handle catalog_category_view
categorypath-{parents-url-keys-here}
. So if the category is Electronics->Cellphones this class will be categorypath-electronics-cellphones
.category-{category-url-key-here}
. If we use the same example as above then this value will be category-cellphones
.In conclusion you can add some styles to what the prices for the class catalog-category-view
and 'cancel' these styles for your specific categories using the the conventions above.