Results 1 to 9 of 9
  1. #1

    Default Product Listing Image Swap

    I've found several mods that do all sort of nifty things when you hover over an image in the product information page but what I'm looking for is a way to display the larger image of a thumbnail when hovering over it in the Product Listing Page. You know, the page you go to when you click on a category.

    Here is what I have and what I want to do;

    When I click on a category it displays product thumbnails 3 columns wide on the right side of the page and on the left side of the page it shows the category image.

    Something like this:

    x x x --------------------
    x x x | category image |
    x x x --------------------

    (sorry for the rudimentary example).

    What I want is when I hover over one of the thumbnails on the left it will swap the image on the right with the large version of the thumbnail.

    Hope this makes sense. Is there anyway to do this?

  2. #2

    Default Re: Product Listing Image Swap

    Nevermind I've managed to figure this out for my self. In case anyone has a similar need here is how I managed to do this.

    Copy includes/templates/template_default/templates/tpl_index_categories.php to includes/templates/YOUR_TEMPLATE/templates and edit line 52 as follows:

    Change this
    Code:
    <div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?></div>
    To this
    Code:
    <div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT, 'name="imgSwap"'); ?></div>
    Notice the name tag at the end - name="imgSwap", this is the only change. The name can be anything you want but remember it because you will use it again in a minute.

    Now copy include/modules/product_listing.php to include/modules/YOUR_TEMPLATE and edit lines 166 and 168 (for some reason these lines are identical).

    Change from this
    Code:
    $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
    To this
    Code:
    $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage" onMouseOver=document.imgSwap.src="' . DIR_WS_IMAGES . $listing->fields['products_image'] . '"; width="' . SUBCATEGORY_IMAGE_TOP_WIDTH . '" height="' . SUBCATEGORY_IMAGE_TOP_HEIGHT . '"') . '</a>';
    Basically you are adding the following right afer the class tag:
    Code:
    onMouseOver=document.imgSwap.src="' . DIR_WS_IMAGES . $listing->fields['products_image'] . '"; width="' . SUBCATEGORY_IMAGE_TOP_WIDTH . '" height="' . SUBCATEGORY_IMAGE_TOP_HEIGHT . '"'
    Be very careful with the quotes, if you don't get them right it won't work. You can just copy/paste this code.

    Note the document.imgSwap.src, you will need to use whatever name you used in the other file in this tag, so it would be document.NAME.src.

    That's it. Hope it works for you, enjoy.

    Allen

  3. #3
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,860
    Plugin Contributions
    2

    Default Re: Product Listing Image Swap

    Can you post url of example where your mod works?
    Dezina ZenCart Templates
    Please do not PM for support queries..Post in forums..help others

  4. #4
    Join Date
    Oct 2006
    Posts
    5,486
    Plugin Contributions
    12

    Default Re: Product Listing Image Swap

    I've found several mods that do all sort of nifty things when you hover over an image in the product information page but what I'm looking for is a way to display the larger image of a thumbnail when hovering over it in the Product Listing Page. You know, the page you go to when you click on a category.
    Sound exactly like what ImageHandler2 does, looks like you were trying to reinvent the wheel.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5

    Default Re: Product Listing Image Swap

    Quote Originally Posted by misty View Post
    Can you post url of example where your mod works?
    Unfortunately it's a members only website. You must be approved by the owner to shop so you wouldn't be able to see the products or how this works.

    Sorry.

  6. #6

    Default Re: Product Listing Image Swap

    Quote Originally Posted by yellow1912 View Post
    Sound exactly like what ImageHandler2 does, looks like you were trying to reinvent the wheel.
    My understanding of ImageHandler2 is (and I may be completely wrong on this and if I am where were you when I was searching for an answer ) is that when you hover over a thumbnail you get a larger image that kind of floats next to your pointer. This isn't what I needed.

    I needed a larger image of the thumbnail displayed in a specific place on the page.

  7. #7
    Join Date
    Oct 2006
    Posts
    5,486
    Plugin Contributions
    12

    Default Re: Product Listing Image Swap

    If you just make a small change to the jscript and the css of IH2 you should get exactly what you want as well.

    But anyhow, you get it now, though through another way, it's all good.

    Cheers
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  8. #8

    Default Re: Product Listing Image Swap

    These modifications work similar to this:

    http://www.locomolife.com/swap%20test.htm.

    This isn't my site and is strictly HTML but it demonstrates what I was needing and what the changes I posted will allow Zen Cart to do.

    Oh, and I re-read the documentation on ImageHandler2 and it does what they call a fancy float. This is not what I needed.

  9. #9

    Default Re: Product Listing Image Swap

    I should mention that this method used the image for the category. In other words when you hover over a thumbnail it's larger image is displayed in the location where the category image normally would go.

    If you need the category image you will need to add a new image div wherever you want to place the thumbnail's larger view.

 

 

Similar Threads

  1. AJAX Image Swapper - Patch to swap between standard and AIS image display
    By jaycode in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 12 Jul 2010, 11:32 AM
  2. Removing Large Image link with Swap Image on Mouse mod
    By XjamathonX in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 17 Aug 2007, 03:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •