Post by studioorange » Thu Jun 14, 2012 6:04 pm

This modification creates a popup when you click on the image in the category page. This means you will not see the product page itself. You can still reach the product page by clicking the name of the product in the category page.

I received a clients feature request but could not find the answer on these forums neither via google. The question was, is it possible to have the popup image on the category page instead of the product page.

It took me some time to figure it out but i succeeded. ;)
I use version 1.5.2.1 and installed fancybox.
This is what you have to do:

Dowload fancybox from: https://github.com/fancyapps/fancyBox/zipball/v2.0.6
Unzip Fancybox and upload the whole directory to catalog/view/javascript/jquery
After uploading rename the "fancyapps..." dir to "fancybox"

Open catalog/controller/product/category.php in your favorite editor and go to line 101 and the following code:

Code: Select all

if ($category_info['image']) {
				$this->data['popup'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
			} else {
				$this->data['popup'] = '';
			}
Then scroll down to line 196 and add:

Code: Select all

'popup'	      => $this->data['popup'] = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')),
Save the controller file and open up the category template file catalog/view/theme/default/template/product/category.tpl.
Scroll to line 73 and replace the line starting with "<div class="image">" with the following:

Code: Select all

<div class="image"><a href="<?php echo $product['popup']; ?>" title="<?php echo $product['name']; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a></div>
Then save the template file.

To get this all working fancybox needs to be enabled, so go ahead and open catalog/view/theme/default/template/common/header.tpl

Make sure you add the following items to the header:

Code: Select all

<script type="text/javascript">
	$(document).ready(function() {
		$(".fancybox").fancybox();
	});
</script>

<!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="catalog/view/javascript/jquery/fancybox/lib/jquery.mousewheel-3.0.6.pack.js"></script>
<!-- Add fancyBox -->
<link rel="stylesheet" href="catalog/view/javascript/jquery/fancybox/source/jquery.fancybox.css?v=2.0.6" type="text/css" media="screen" />
<script type="text/javascript" src="catalog/view/javascript/jquery/fancybox/source/jquery.fancybox.pack.js?v=2.0.6"></script>
Save the header file. I removed the colorbox item from the header. Just to be shure.

Now if everything went well you should be able to see popup images on the category page.

Note - this will work when you select the category list. i haven't tried it using product grid.

Good luck!

Newbie

Posts

Joined
Thu Jun 14, 2012 5:37 pm

Post by pstruh » Thu Apr 11, 2013 6:08 am

doesnt work for me. I am on 1.5.4, but after the modification, no change.

Any idea?

Newbie

Posts

Joined
Sun Apr 07, 2013 6:44 pm

Post by studioorange » Thu Apr 11, 2013 4:21 pm

so far no idea, but i will try on a test environment en let you know

Newbie

Posts

Joined
Thu Jun 14, 2012 5:37 pm

Post by pstruh » Thu Apr 11, 2013 6:48 pm

It works, I got typo ine code:) thanks.

How to achieve to zoom image on category page ?

Newbie

Posts

Joined
Sun Apr 07, 2013 6:44 pm

Post by RemcoJ » Thu Jun 13, 2013 8:03 pm

When changing from Grid to List view the popup functionality stops working. This is due to the javascript in the category.tpl file. To fix it, add $(".colorbox").colorbox(); or $(".fancybox").fancybox(); depending on what you are using, at the end of the 'display' script...

Newbie

Posts

Joined
Thu Jun 13, 2013 8:00 pm
Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests