Jump to content

Home featured: how to change from 4 to 3 columns?


Recommended Posts

you can edit these line
{assign var='nbItemsPerLine' value=4}
in file
../modules/homefeatured/homefeatured.tpl


When I changed value=4 to value=3
The are only 3 columns.
However, the col 1 & 2 remain unchanged, only the 3th column become wider (a merged of col 3 & 4), it look like the col 4 is there but there is nothing inside.

How to make all 3 cols equal? and the content are center aligned?

Thanks.
Link to comment
Share on other sites

also, why not just go to modules>>configure and change display to three, rather than editing templates to do this?

That is an option on the Module. But yes, if you have less than 4 you need to do need to re-style, if you don't use it already, install firebug for Firefox, it will help you a lot

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 1 year later...

I know what you mean.

Just copy the code from the file product-list.tpl to homefeatured.tpl that solved my problem.

Or maybe you can use this piece of code:

<!-- MODULE Home Featured Products -->
{if isset($products)}
   <!-- Products list -->


{l s='Featured products' mod='homefeatured'}



getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />

{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}

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


               {if $product.on_sale}
{l s='On sale!'}
               {elseif ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product.reduction_from))}
{l s='Price lowered!'}
               {/if}
               {if !$priceDisplay || $priceDisplay == 2}{convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if}{/if}
               {if $priceDisplay}{convertPrice price=$product.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx'}{/if}{/if}









   <!-- /Products list -->
{/if}
<!-- /MODULE Home Featured Products -->

Link to comment
Share on other sites

  • 1 month later...

I changed my featured products columns from 4 to 3 evenly spaced columns in my global.css file. I don't know code, so I try to keep my editing very simple.

Around Line 975: I changed the middle padding to 22px. If your images are bigger, you may need to change it to 20px or less.

padding: 0 22px 1px;

I use Firebug add-on for Firefox to show me what code to edit. Hope this helps.

27422_ETnjX04yvH0dCKR7A8c5_t

Link to comment
Share on other sites

  • 3 months later...

Aim : To change 4 products per line to 3 products per line in featured products.
MyConfig : Using WAMP and default prestashop theme

Well following from above replies and spending hours, I realized that the solution is in 2 steps :

1. Open C:\wamp\www\themes\prestashop\css\global.css. Search for

#center_column .products_block ul li

and change the width parameter from

width: 133px;

to

width: 178px;

.


Why 178 ? Because 133 x 4 / 3 = 178.
Now save global.css and refresh the home page. Job is done but images are still "left" aligned. To fix this, go to step 2.


2. Open C:\wamp\www\modules\homefeatured\homefeatured.tpl. As Ardian has mentioned above, change

{assign var='nbItemsPerLine' value=4}

to

{assign var='nbItemsPerLine' value=3}

and also change

width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}

to

width="{$homeSize.width}" style="margin-left: 24.5px;" alt="{$product.name|escape:html:'UTF-8'}




Why 24.5 ? Because (178 - 129) / 2 = 24.5, where 129 = width of image and 178 = width of column from Step 1.


Hope the above explanation renders the topic [sOLVED] ;-) Do let me have your comments.

  • Like 2
Link to comment
Share on other sites

  • 7 months later...

Hi, I also wanted to changed the home page featured products from 4 to 3 columns.

I changed the homefeatured.tpl as suggested and it didn't affect anything, I even cleared all the code out of the file, uploaded it and nothing changed at all!
I'm new to Prestshop and I'm finding it quite a strange piece of software, very good but also very weird.

Link to comment
Share on other sites

  • 5 months later...
  • 11 months later...

Aim : To change 4 products per line to 3 products per line in featured products.

MyConfig : Using WAMP and default prestashop theme

 

Well following from above replies and spending hours, I realized that the solution is in 2 steps :

 

1. Open C:\wamp\www\themes\prestashop\css\global.css. Search for

#center_column .products_block ul li

and change the width parameter from

width: 133px;

to

width: 178px;

.

 

 

Why 178 ? Because 133 x 4 / 3 = 178.

Now save global.css and refresh the home page. Job is done but images are still "left" aligned. To fix this, go to step 2.

 

 

2. Open C:\wamp\www\modules\homefeatured\homefeatured.tpl. As Ardian has mentioned above, change

{assign var='nbItemsPerLine' value=4}

to

{assign var='nbItemsPerLine' value=3}

and also change

width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}

to

width="{$homeSize.width}" style="margin-left: 24.5px;" alt="{$product.name|escape:html:'UTF-8'}

 

 

Why 24.5 ? Because (178 - 129) / 2 = 24.5, where 129 = width of image and 178 = width of column from Step 1.

 

 

Hope the above explanation renders the topic [sOLVED] ;-) Do let me have your comments.

 

 

Hi!!! I would like to ask, how about adding an item per line.. The default item per line is four, right? I want to make it 5. Can you please help me. :)

Link to comment
Share on other sites

  • 10 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...