Jump to content

Assigning different image size of a product, according to Category


igor.i
 Share

Recommended Posts

Greetings,

 

I would like to assign different image size of a product, according to Category: for the Packages (category ID = 261), the image size should be larger than the assigned size for other products/titles. 

I added new category in Images (see att. post-429719-0-71700000-1416620400_thumb.png), "box_default_pack" (no.9, 900x467px.) and then added the following code in themes/default/product.tpl, at lines 178-189:

{if $have_image}
		{if $Category->id == 261}
		<span id="view_full_size">
				<img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')}" {if $jqZoomEnabled}class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'box_default_pack')}"{else} title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" {/if} id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
				<span class="span_link">{l s='View full size'}</span>
			</span>
			
		{else}
			<span id="view_full_size">
				<img src="{$img_prod_dir}{$lang_iso}-default-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />
				<span class="span_link">{l s='View full size'}</span>
			</span>
			{/if}
		{else}
			<span id="view_full_size">
				<img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')}" {if $jqZoomEnabled}class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox_default')}"{else} title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" {/if} id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
				<span class="span_link">{l s='View full size'}</span>
			</span>
		{else}
			<span id="view_full_size">
				<img src="{$img_prod_dir}{$lang_iso}-default-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />
				<span class="span_link">{l s='View full size'}</span>
			</span>
		{/if}

Unfortunately, I am testing this online and can not see where the error is - all I get is a blank page.

If I am to assign smarty code, where (in which file/s) should I do it, and what the code should be?

 

I apologize if this has been answered; I did my best to find the answer.

 

I am using PrestaShop™ 1.5.3.1

 

Any help would be much appreciated!  :)

Share this post


Link to post
Share on other sites

Let's re-format the code a iittle:

 

 

  1. {if $have_image}
  2.     {if $Category->id == 261}
  3.         <span id="view_full_size">
  4.             <img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')}"
  5.             {if $jqZoomEnabled}
  6.                 class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'box_default_pack')}"
  7.             {else}
  8.                 title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}"
  9.             {/if}
  10.             id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
  11.             <span class="span_link">{l s='View full size'}</span>
  12.         </span>
  13.     {else}
  14.         <span id="view_full_size">
  15.             <img src="{$img_prod_dir}{$lang_iso}-default-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />
  16.             <span class="span_link">{l s='View full size'}</span>
  17.         </span>
  18.     {/if}
  19. {else}
  20.     <span id="view_full_size">
  21.         <img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')}"
  22.         {if $jqZoomEnabled}
  23.             class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox_default')}"
  24.         {else}
  25.             title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}"
  26.         {/if}
  27.         id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />
  28.         <span class="span_link">{l s='View full size'}</span>
  29.     </span>
  30. {else} <-- Seems to have 2 x else
  31.     <span id="view_full_size">
  32.         <img src="{$img_prod_dir}{$lang_iso}-default-large_default.jpg" id="bigpic" alt="" title="{$product->name|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />
  33.         <span class="span_link">{l s='View full size'}</span>
  34.     </span>
  35. {/if}

 

 

Seems to have 2 x else

pascal

Edited by PascalVG
Editor messed up. reformatted text... (see edit history)

Share this post


Link to post
Share on other sites

Thanks for the reply and the suggestion, PascalVG.

 

I tried removing any of both {else} tags, but the results are not good. Will create a localhost envoriment soon and will let you know.

 

Best regards,

II

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More