Jump to content

Recommended Posts

Hi

Here is Home featured rollover image code and file tested on version 1.4+

This contain small modification in original prestashop homefeatured module. you can achieve roll over image functionality by following these simple steps or replace homefeatured.php and homefeatured.tpl with attached files this is not complete module it contains only two file homefeatured.php and homefeatured.tpl

 

STEP 1

 

Replace following line in homefeatured.tpl

 

<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" class="vky"/>

 

Replace with ---

 

{* ---- modified portion to show rollover image on home featured product start here *}

<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" class="vky"/>

{foreach from=$addimages key=k item=v}

{if $k==$product.id_product}

<img src="{$link->getImageLink($product.link_rewrite,$product.id_product|cat:"-"|cat:$v, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.legend|escape:htmlall:'UTF-8'}" style="display:none" class="v" />

{/if}

{/foreach}

{* ---- modified portion to show rollover image on home featured product End here *}

 

 

STEP2

 

add following js at the end of page

 

{* additional jquery code to rollover image on home featured product *}

{literal}

<script type="text/javascript">

$(document).ready(function(){

$("img.vky").mouseover(function(){

if ( $(this).next("img").length > 0 ) {

$(this).next("img").show();

$(this).hide();

}

});

$(".v").mouseout(function(){

$(this).hide();

$(this).prev("img").show();

});

});

</script>

{/literal}

 

STEP3

 

homefeatured.php

 

< Replace following code in function hookHome($params) near line no 99 >

 

$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));

 

 

Replace with the code

$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));

$p=array();

for($i=0;$i<count($products);$i++){

$product=$products[$i];

unset ($pid);

$pid=$product['id_product'];

$sql= "SELECT * FROM `"._DB_PREFIX_."image` WHERE `id_product` = '{$pid}' AND cover = '0' ORDER BY `id_image` ";

$results = Db::getInstance()->ExecuteS($sql);

$result=$results[0];

$p[$pid]=$result['id_image'];

}

$smarty->assign('addimages',$p);

 

 

Note- some time it is possible editor parse some code. It will be better to download files attached below

homefeatured-rooloverimages-file.zip

  • Like 4

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 2 weeks later...
  • 1 month later...
  • 4 weeks later...

If anyone is still looking for it, in this other topic is the answer, tested in PS 1.4.8.2

 

Hi all and thank you vivek tripathi for your share.

For those of you who get productimg a blank array (meaning that the script is showing images), change $cat_products from the script that goes inside the categorycontroller.php with : $this->cat_products .Just like this

 

 for($i=0;$i<count($cat_products);$i++)
  {
$image_array[$i]= $this->category->getProductsimg($cat_products[$i]['id_product']);
  }

 

with this one

 

  for($i=0;$i<count($this->cat_products);$i++)
	   {
   	 $image_array[$i]= $this->category->getProductsimg($this->cat_products[$i]['id_product']);
	   }

 

And I advice you to add this code inside a controller/class that you create in the folder override.

Hope it helps!

 

http://www.prestashop.com/forums/topic/96085-rollover-image-in-product-list/page__p__895581?do=findComment&comment=895581

Edited by fogolin (see edit history)

Share this post


Link to post
Share on other sites

  • 4 months later...
  • 1 month later...
  • 3 weeks later...
  • 2 months later...
  • 1 month later...
  • 2 years later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

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