Post by chokoret » Tue Jun 21, 2011 7:30 am

I am trying to make product list thumbnails rollover..
so it will show the image uploaded from admin - product data ,
and once the cursor is on the image, the first additional image that's been uploaded from admin - product image will appear..
looking at catalog/controller/product/category.php and category template file but could not find the way yet :(

Can anyone help me out with this issue please? :'(

for version 1.5
Last edited by chokoret on Thu Sep 01, 2011 11:59 pm, edited 1 time in total.

User avatar
New member

Posts

Joined
Thu Jun 09, 2011 1:26 am
Location - Los Angeles, CA

Post by chokoret » Wed Jun 22, 2011 1:58 am

figured out..

User avatar
New member

Posts

Joined
Thu Jun 09, 2011 1:26 am
Location - Los Angeles, CA

Post by leclatante » Thu Jul 28, 2011 10:45 pm

care to share how you have figured it up?

Newbie

Posts

Joined
Thu Jul 28, 2011 9:51 pm

Post by chokoret » Thu Sep 01, 2011 7:49 am

Ok, Let me share How i figured this out -
I actually couldn't share because i figured out only for in my own need while I don't really understand how it works, so couldn't really post codes and explain, but now I see how it did.

First of all, you will need to find an open resourse of javascript that does image rollover in .js file format.
I can not share js file i currently am using because im not sure if im allowed to share this one, but i'm pretty sure there are many free js source that do rollover image.
or I found this : http://jehiah.cz/a/simple-swap (download js file i=on the bottom of page), this seems working similar with the one I have.

So let me just post pretending im using that js above.
1. download above js file and upload it in your catalog theme folder.
for example, i placed my js file in catalog/view/theme/*your theme*/js/simpleswap.js

2.open catalog/controller/product/category.php

and find

Code: Select all

$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
				} else {
					$image = false;
				}
then add this

Code: Select all

$images = $this->model_catalog_product->getProductImages($result['product_id']);

				if(isset($images[0]['image']) && !empty($images[0]['image'])){
						$images =$images[0]['image'];
					} 
Find

Code: Select all

$this->data['products'][] = array(
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
And Add

Code: Select all

'thumb_swap'  => $this->model_tool_image->resize($images, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),

3. Open catalog/view/theme/*yourtheme*/template/product/category.tpl
ADD this on very top

Code: Select all

<script language="javascript" src="catalog/view/theme/*yourtheme*/js/simpleswap.js"></script>
(!! put your own location of js file for scr=" "!!)

find

Code: Select all

      <?php if ($product['thumb']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
      <?php } ?>
and replace with

Code: Select all

       <?php if ($product['thumb_swap']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img oversrc="<?php echo $product['thumb_swap']; ?>" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" style="border:none"/></a></div>

          <?php } else {?>

      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" style="border:none"/></a></div>

      <?php } ?>

Actually I have not tested this, since i am using different javascript, but as long as there's no error on the script above, this would work :)

User avatar
New member

Posts

Joined
Thu Jun 09, 2011 1:26 am
Location - Los Angeles, CA

Post by odaniboy » Wed Sep 14, 2011 9:18 pm

SO MUCH THANKSSSSSSSSSSSSSS CHOKORET.
works perfectly...
saved my life XD...

\o/

Newbie

Posts

Joined
Wed Aug 24, 2011 7:22 am

Post by Morita Design » Sat Sep 24, 2011 8:05 pm

Very Nice one Mate!

Newbie

Posts

Joined
Sat Sep 24, 2011 8:04 pm

Post by mpshop » Wed Nov 16, 2011 4:49 am

Thanks for the code. Works great.

Wondered, do you know which file to place the code in for this to work on the featured product page on the front ? I tried product.tpl but its not working.

Thanks

Newbie

Posts

Joined
Mon Nov 14, 2011 3:02 am

Post by maplebritt » Sat Dec 31, 2011 4:12 pm

Help! not sure what i am doing wrong.... tried this using opencart_v1.5.1.3.1 and every time i goto category view i get a blank page.... anyone have any ideas?

Newbie

Posts

Joined
Sat Dec 31, 2011 4:42 am

Post by tylerdurden1973 » Sun Feb 10, 2013 8:15 pm

tested. work! thanks!!! and if I want to show all the images in rollover?
thanks


Posts

Joined
Sun Feb 10, 2013 8:13 pm

Post by thauka » Thu Jun 13, 2013 8:31 pm

You simply ROCK!! :)

Newbie

Posts

Joined
Sat Mar 30, 2013 6:04 pm

Post by fmanso » Fri Sep 27, 2013 3:54 am

If anyone is getteing any php error about string to array conversion:

Code: Select all

$images = $images[0]['image']; 
Since you are using the same name for a String and the array.

Change to something like:

Code: Select all

$swapImg = $images[0]['image']; 
and set $swapImg to load instead of $images

Newbie

Posts

Joined
Thu Sep 12, 2013 4:36 am
Who is online

Users browsing this forum: No registered users and 10 guests