Change sub-categories to grid view

by John on Jun.30, 2009, under Hints/Tips/Hacks

Below is the code to change your sub-categories page from the list in the default theme to a grid with 3 column and no descriptions.

Overwrite the following code in your global.css file should be about line 1500, you will need to edit the colours to match your theme as this is not the default theme.

You will also need to replace your product-list.tpl file with this one for v1.1 and this one for v1.2

You will also need to change your pagination to suit the new 3 column format.  Just edit the pagination.php file in the root folder.  Near the top you will see: $nArray = array(10, 20, 50). Just alter the number to suit the new layout.

/* product-list.tpl */
ul#product_list{ margin-top:2em; list-style-type:none; }
ul#product_list li {
background: #FFF;
padding: 4px;
height:220px;
clear:both;
margin-bottom:0.3em;
float: left;
width: 29%;
height: 255px;
margin-right: 8px;
clear: none;
margin-left:4px;
margin-top:2px;
}
ul#product_list li a {
text-decoration:none;
color:#000;
}
ul#product_list a.product_img_link{
border: solid 1px #d0d3d8;
float:left;
margin-right:0.6em;
margin-left:15px;
margin-top:30px;
}
ul#product_list li h3{ margin:0.4em 0; width:160px;padding-bottom:2px;height:10px; text-align: center;}
ul#product_list li .new{
background:transparent url(../img/flag_new_bg.jpg) repeat-x scroll 0%;
border:1px solid #488C40;
color:white;
font-size:0.6em;
font-weight:bold;
margin:0pt 1em 0pt 0pt;
padding:0pt 0.4em;
text-transform:;
vertical-align:0.3em;
}
ul#product_list li p.product_desc{ font-size:0.92em; }
ul#product_list li div.center_block{
float:left;
width:100%;
}
ul#product_list li div.right_block{
float:left;
text-align:center;
margin-left:2em;
margin-top:0.5em;
display:inline;
}
ul#product_list li .discount{
color:#da0f00;
text-transform:;
font-weight:bold;
display: block;
}
ul#product_list li .on_sale{
color:#da0f00;
text-transform:;
font-weight:bold;
display: block;
}
ul#product_list li .reduction {
display: block;
margin-bottom: 0.3em;
}
ul#product_list li .price{
display: block;
font-size: 170%;
margin-bottom: 0.2em;
}
ul#product_list li span.availability{
color:#000;
font-size:0.9em;
}
ul#product_list li a.button{ margin-top:0.5em; }

VN:F [1.9.3_1094]
Rating: 4.4/5 (9 votes cast)
Change sub-categories to grid view, 4.4 out of 5 based on 9 ratings
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MisterWong
  • Reddit
  • StumbleUpon
  • Twitter
  • Add to favorites
  • RSS
  • Technorati

Related posts:

  1. Drop-down Categories Block Module
  2. Sliding Navigation categories block module
  3. Modified Categories Block Module
  4. Sliding Categories Block using accordion
  5. How to – delete “0 products” text header in categories pages

:, ,

31 Comments for this entry

  • Tropical Dream

    it didn’t work for me in Prestashop 1.2. When I uploaded your new product-list.tpl, the products did not display correctly. It was still in a single column but the pictures of the products and the buttons are completely mislplaced. Is this compatible with 1.2?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • boubou

    Hello,
    “Just edit the pagination.php file in the root folder. Near the top you will see: $nArray = array(10, 20, 50). Just alter the number to suit the new layout”

    i use ‘prestashop 1.2′.
    I changed to : $nArray = array(12, 24, 48)
    The ’select’ in the bottom of the page works fine, i see 12, 24 and 48 but still 10 products by page !
    If i use an echo $n; i can see in the pagination.php that the value is still 10 !
    Do you have a solution for that please ?
    Thank you

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • boubou

    Hello,
    i found the solution : in the Back Office, preferences, products, you have to change the number of products by page.

    Thank you for your great website and helpful hints ^^

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • rodrigo

    How can i made it to disply the short product description with the format i want, example:

    (short desc display under the picture)

    - WINDOWS
    - 200 MHZ
    - SPNISH
    - etc

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • admin

      It is possible to stop prestashop removing HTML formatting by removing a section of code from the product-list.tpl file as below.

      {$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}

      This is the line that concerns the short description for product lists, if you remove the section that says |strip_tags:’UTF-8′ then any html that you enter as a short description will display on the front-end.

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • Andy

    Any way to have attributes below short description?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • admin

      I presume you are refering to the product page and not the category page.

      If you edit your product.tpl file and move the section that refers to attributes up the page so that it is above the code for the price block.

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • Andy

    Im refering to category listing. I need this same attributes like on product page. Do you think simply move all block from product.tpl to product_list.tpl will by enough ?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • admin

      So you want to be able to select attributes from the categories pages? There is no module currently for that, it would need alteration of some presta files. Moving the attributes code from product.tpl is unlikely to work.

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • Andy

    Yes – exactly what I need is have possibility to get similar products with this same features (like “Similar to this product are also:”).

    It will by store with woman underwear, so it will by great to have listing all strings in this same size and color ;) what do you think ?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • Brian

    Could you explain a way to make the view, grid or list, selectable by the customer as it is in Magento?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • admin

      You need to get a coder to acheive this as as far as I am aware no one has created that kind of module

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • steve

    hello i used your code to form a grid layout it works like a charm..i would just like to have 4 columns instead of 3

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • admin

      You would need to change the width of ul#product_list li { in your global.css to make them smaller to fit more into the space.

      VN:F [1.9.3_1094]
      Rating: 5.0/5 (1 vote cast)
  • Richard

    Hi there,

    First of all, thank so much for the great modification, works like a charm.

    I do have one question that should be relatively simple, just wondering how to get the “add to cart” button back as it is now removed with your script.

    Any support would be greatly appreciated as I am a bit of a noob when it comes to PHP.

    Richard.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • _hide

      You need to add the following code in your product-list.tpl file.

      <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$base_dir}cart.php?add&id_product={$product.id_product|intval}&token={$static_token}" rel="nofollow">{l s='Add to cart'}
      {else}
      <span class="exclusive">{l s='Add to cart'}
      {/if}

      If you add it just above the code for the view button it should look ok.

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • justin

    The only problem with this method is if the description is too long or goes beyond the set height it will break the grid layout…

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    • _hide

      The description code isnt include in the product-list.tpl file that I have included, so that wouldnt be a problem if you use it.

      VN:F [1.9.3_1094]
      Rating: 0.0/5 (0 votes cast)
  • Thor

    Hi,,

    I have proplem with”Price lowered”
    It goes on same place and nameof the product is?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • jepetto

    hi :) ,
    is this gonna work in PS 1,2,5 or 1,3,0 ?
    thank for everything

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • tony

    This worked great for me. the only problem I have is when the number of products is not divisible by 3, the page navigator at the bottom screwed up.
    Meaning, the nav bar at the bottom jump up to the “not enough 3 products” line, instead of staying at the bottom.

    Please see the pic:

    http://i233.photobucket.com/albums/ee1/harrypotter30022003/error.jpg

    Any suggestion?

    Thanks in advance

    P.S: How can i get the comment module with captcha and commenters’ details like yours? thanks again for this great work!!!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • tony

    this comment module in your page, just below this. Since the comment module pre-installed in prestashop is not very convenient since it requires guest to register and login… also no recaptcha so is there any better comment module similar in this website ???

    How about my error? any idea??

    Thank you very much…

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • Ivan

    Hello, the module is very good, thanks for this module, and, just i have a problem, the product link is bad, because just take a little portion of the image.

    http://www.sistemform.com/pruebas/tienda/manufacturer.php?id_manufacturer=3

    and i was made change in global.css the ul#product_list a.product_img_link and nothing, Could you help me please?.

    Thanks.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • Ivan

    Hello, well i the solution of my problem is just put position:absolute; in the seccion:

    ul#product_list a.product_img_link{

    float:left;
    margin-right:0.6em;
    margin-left:35px;
    margin-top:-1px;
    position:absolute;

    }

    and the problem dissapear.

    Thanks for the module.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
  • jose

    Hi All,
    thanks for the piece of code, it saved me a lot of time.
    The point is that i get the same thing than Tony (23rd May)
    When the the number of product listed is not divisible by 3
    the pagination controls are not shown at the botton of the page.

    Any suggestion?

    Thanks in advance,
    Jose

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Popular tags