Advertisement
  1. Web Design
  2. Magento

Magento Theme Development: Category Page, Part 2

Scroll to top
Read Time: 5 min
This post is part of a series called Magento Theme Development.
Magento Theme Development: Category Page, Part 1
Magento Theme Development: Product Page, Part 1

In the previous article on category pages, we edited the toolbar, grid and list layout. In this second article on customizing the category page, we'll customize the sidebar and do some CSS fixes.

First of all, we'll add some components in the sidebar, so that we can style them. Here, for the purpose of demonstration, we'll just add one or two components and modify them. That'll give you ample understanding of how you can modify the other sidebar components as well. 

For now we'll just add 'compare products' and a sidebar banner to the sidebar. We'll do that from the local.xml code. If you remember from the first articles of the series, you can find the local.xml file in the layout folder of your theme file.

We'll add a reference to the left section, and then add a banner and compare product module in the sidebar, using the code below:

1
<reference name="left">
2
    <block type="catalog/navigation" name="left_categories_nav" before="-" template="catalog/navigation/left.phtml"/>
3
    <block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
4
        <action method="setImgSrc"><src>images/banner-small-01.png</src></action>
5
        <action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>
6
        <action method="setLinkUrl"><url>checkout/cart</url></action>
7
    </block>
8
    <block type="catalog/product_compare_sidebar" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
9
</reference>

Use it just as a reference code—you can add more modules or banners using the same procedure.

If we look at our HTML design, we'll notice that all components are nicely designed, especially the heading part, which has multiple colors in it. 

Sidebar Module

Whereas our current design is little off, though we can modify the design through CSS, but we need to modify the HTML to add classes for different colors in the heading. 

Sidebar Before editingSidebar Before editingSidebar Before editing

To modify the HTML, we'll first enable template hints, and find out that the file responsible for it is \template\catalog/product/compare/sidebar.phtml.

Now we'll open up this sidebar.phtml file, and compare it with the HTML code.

Our design HTML code for the sidebar looks like this:

1
<div class="product-tag leftbar">
2
    <h3 class="title">Products <strong>Tags</strong></h3>
3
    <ul>
4
      <li><a href="#">Lincoln us</a></li>
5
      <li><a href="#">SDress for Girl</a></li>
6
      <li><a href="#">Corner</a></li>
7
      <li><a href="#">Window</a></li>
8
      <li><a href="#">PG</a></li>
9
      <li><a href="#">Oscar</a></li>
10
      <li><a href="#">Bath room</a></li>
11
      <li><a href="#">PSD</a></li>
12
    </ul>
13
</div>

We can see that the heading has the h3 tag with a class of title, and it has the strong tag around the heading parts, which have a different color. 

For this, we'll replace the block-title div with this:

1
<h3 class="title"><?php echo $this->__('Compare ') ?><strong><?php echo $this->__('Products') ?>
2
    <?php if($_helper->getItemCount() > 0): ?>
3
        <small><?php echo $this->__('(%d)', $_helper->getItemCount()) ?></small>
4
    <?php endif; ?>
5
</strong></h3>

Refresh the page, and it should look quite close to our HTML design now. You can add and style other sidebar components in a similar way.

Now that we are done editing the phtml files, let's start fixing the CSS styles.

We'll start fixing styles from the top. The first component which needs our attention is the page heading. As we can see, it is quite off, and is not close to our HTML requirements.

Heading before stylingHeading before stylingHeading before styling

We'll add these lines in our new CSS file to style the heading.

1
.page-title h1{
2
3
    font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
4
    float: left;
5
    position: relative;
6
    width: 100%;
7
    margin-bottom: 15px;
8
    font-size: 24px;
9
    color: #2f2f2f;
10
    font-weight: 300;
11
    padding-bottom: 5px;
12
    text-align: center;
13
    background: url(../images/hadingBg.jpg) no-repeat center;
14
    line-height: 3;
15
16
}
17
18
.col-md-9 .toolbar{
19
    float: none;
20
	border:none;
21
	background-color: transparent;
22
	padding-left: 0;
23
}

Here we have just given it a good text font, line height, text align, background image, etc. Also, we have made the background transparent with no border. It should look like this now:

Heading after stylingHeading after stylingHeading after styling

Next we need to modify the toolbar section. For that we'll add these styles in our CSS file:

1
.toolbar .sorter > .view-mode{float: left;}
2
3
.toolbar .sorter > .view-mode .grid {
4
    background-image: url(../images/grid-icon.png);
5
    width: 25px;
6
    height: 25px;
7
    background-position: 0px 0px;
8
}
9
.toolbar .sorter > .view-mode .list {
10
    background-image: url(../images/list-icon.png);
11
    width: 25px;
12
    height: 25px;
13
    background-position: 0px 0px;
14
}
15
.toolbar .sorter select{font-size:12px;}

Here we have just specified some background images, width, height, etc., and it'll pretty much do the trick. The page should look like this:

Toolbar after stylingToolbar after stylingToolbar after styling

Now, let's start editing the products section in grid view. The page looks like this now:

Grid View before stylingGrid View before stylingGrid View before styling

We'll just have to make some width and hover style adjustments. Also the price color needs changing. We'll do all that by adding these CSS lines:

1
.category-products .products-grid--max-4-col > li {width:30%;}
2
.category-products .products-grid--max-4-col > li .view-eighth:hover .mask {top:170px;}
3
.item .price-box .price, .price{color:black;}

Now the grid section should look like this:

Grid View after stylingGrid View after stylingGrid View after styling

In the last part we need to fix the products section in the list mode. It currently looks quite messed up, but don't worry—a few lines of CSS will set everything right. 

List View before StylingList View before StylingList View before Styling

To make it look good, we'll use these CSS styles:

1
.item .product-list-description .price-box .price{float: left;
2
    font-size: 28px;
3
    color: #b39a64;
4
    margin-right: 10px;}
5
.products-list .products .thumbnail{border: medium none;
6
    float: left;
7
    margin: 0;
8
    padding: 10px;
9
    position: relative;
10
    width: 18%;
11
    height: auto;}
12
.products-list .products{min-height: 100px;}
13
14
.products-list .products:hover {
15
    background: #fff;
16
    border-color: #b39a64;
17
    -webkit-box-shadow: 0 0 5px 1px #d3d3d3;
18
    box-shadow: 0 0 5px 1px #d3d3d3;
19
}
20
.products-list .products {
21
    border: 1px solid #e1e1e1;
22
    position: relative;
23
    overflow: hidden;
24
    background: #fff;
25
    padding: 15px;
26
    margin-top: 15px;
27
    min-height: 150px;
28
}
29
.products .button {
30
    background: #b39a64;
31
    color: #fff;
32
}
33
.button:hover, button:hover {
34
    border: 1px solid #b39a64;
35
}
36

Here we have set the product image width, floated the price to the right, given the whole section a nice background, border and hover effect, and modified the button slightly. The page should look something like this:

List view after stylingList view after stylingList view after styling

With all this done, your catalog page should look nice and close to our HTML design requirements. You may need some other CSS fine-tuning, but other than that you are all set.

In the next article of this series, we'll start editing the product detail page. 

Please do leave your suggestions and feedback in the comments section. We'll be looking forward to it.

Advertisement
Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Web Design tutorials. Never miss out on learning about the next big thing.
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.