Jump to content

Assign new image sizes to a different layout


Recommended Posts

Hi, as I posted here I've followeb a tutorial to use a different layout per category and at this moment it is working nice to me. I've done something simple in most categories of my shop, I show a product-list.tpl with 4 product columns but in an specific one my custom product-list.tpl shows 2 columns.

 

Now I would assign the diferent image sizes that I've created on Back Office/Preferences/Images to my new custom layout so they appear in my product list images and inside my products image.

 

I haven't found this lines in product-list.tpl, do you know what I need to modify?

 

Thanks in advance and hope to explained well my issue!

Link to comment
Share on other sites

about what ps version you're talking?

Sorry, forgot it. I'm working on PS 1.6.0.9 and the default-bootstrap template. Website is this one: lamallorquina.onesixstudio.com/en/

 

And what I want is to have a 2 columns (already done) of 456x578px images (already created in Preferences/Images) in "HOMEWEAR" category.

Link to comment
Share on other sites

im confused no

so you want to use different imagetype for only one category?

im affraid that it will be a little hard to achieve

you will need to edit each template file where the product image appears

 

please shed light on my question, will see what we can do with this :-)

Link to comment
Share on other sites

im confused no

so you want to use different imagetype for only one category?

im affraid that it will be a little hard to achieve

you will need to edit each template file where the product image appears

 

please shed light on my question, will see what we can do with this :-)

 Arg, I thought it was quite simple :(

 

Yes I wanted to use images of 456x578px on HOMEWEAR and keep my 218x218px images on the rest of the site. Or what's the same use squared images on my site but rectangular vertical on HOMEWEAR.

 

I've already created a folder (theme/layouts/categories/homewear) and changed CategoryController.php to read only my custom category.tlp and product-list.tlp for HOMEWEAR and read the original files for the rest of the site. Don't know if this helps to do it easier :blush:

Link to comment
Share on other sites

what to do:

1 - create new imagetype with thumb size equal to your expectactions, name it "homewear_imagetype"

2 - modify product-list.tpl file, for example, if your homewear category id is 15 use this code:

 

change line:

<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" />

to:

{if isset($smarty.get.id_cat)}
  {if $smarty.get.id_cat==15}
    <img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'homewear_imagetype')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}"itemprop="image" />
  {else}
    <img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" />
  {/if}
{else}
<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" />
{/if}
Link to comment
Share on other sites

Hey Vekia it worked! In fact I tried something similar but the trick was to remove this part "width="{$homeSize.width}" height="{$homeSize.height}"

 

I looks nice now ^^ Do you know where can I do the same with the inside product image? There's no "home-default" tag in product.tpl. No need, editet ProductController.php to call my custom product.tpl and changed "large_default" image tag by my custom tag.

 

Thanks for all help!

Edited by NicePack (see edit history)
Link to comment
Share on other sites

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...