Zen Cart Logo
Forums / General Questions / How to add an id tag to Main Product Image?

How to add an id tag to Main Product Image?

Locked

Views: 2,521

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
2 Jul 2009, 7:09 AM
#1
erko avatar

erko

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
20
Plugin Contributions:
0

How to add an id tag to Main Product Image?

Hi all,

I'm using Zen Cart 1.3.8a.

This seems like an easy tweak, but I've been going around in circles for hours just trying to find where the HTML string is formed.

I'm trying to add an ID tag to the main product image displayed on a product page. I can't figure out/find where the code is being parsed to resultant HTML.

The file templates\My custom\templates\tpl_modules_main_product_image.php contains the code;

<?php echo zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT);?>

which outputs the HTML

<img src="images/range/CC596.jpg" alt="Slip" title="Slip" width="250" height="341" />

I'd like my HTML to include an ID tag as follows;

<img src="images/range/CC596.jpg" alt="Slip" title="Slip" width="250" height="341 ID='PIC' />

Where can I find the code which builds/parses this resultant HTML?

Hope this makes sense. Any help is appreciated.

Thanks in advance.

Regards
erko

2 Jul 2009, 8:38 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to add an id tag to Main Product Image?

Why do you believe you need an id for this image? It is the only image inside

<div id="productMainImage" class="centeredContent back"> so can be uniquely addressed in the stylesheet with

#productMainImage img {what: ever;}

2 Jul 2009, 11:00 AM
#3
erko avatar

erko

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
20
Plugin Contributions:
0

Re: How to add an id tag to Main Product Image?

Hi Glenn, thanks for the response..

What I'm trying to do is a simple mouseover (on another link/image) to change the main product image..

I.e. My code on the other link is as follows;

<img src="CC596_1.jpg" onmouseover="document.images['PIC'].src='CC596_1.jpg';" width="80" height="60" alt="Slip" />

Basically I'm trying to tweak the original additional images code - to do a mouseover instead of a new popup.

Any ideas?

Eric

2 Jul 2009, 11:04 AM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to add an id tag to Main Product Image?

I believe there is an image swapper module that does this already. You can:

  1. just use that module
  2. look at the module's code to see if it has any pointers for your intended script.

20 years a Zencart User

2 Jul 2009, 11:16 AM
#5
erko avatar

erko

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
20
Plugin Contributions:
0

Re: How to add an id tag to Main Product Image?

Thanks Schoolboy...

Yep I've seen the AJAX Image Swapper - http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_60&products_id=801.

I only saw this after I had tinkered around with my code :wacko:

Just need to add a simple id='PIC'. Will scout around abit more and if no luck - I'll swallow my pride & effort and install the image swapper.

Thanks again.

Anyone?

erko

2 Jul 2009, 12:54 PM
#6
erko avatar

erko

New Zenner

Join Date:
Jun 2009
Location:
Australia
Posts:
20
Plugin Contributions:
0

Re: How to add an id tag to Main Product Image?

Thanks Glenn & Schoolboy for their comments.

Managed to solve this bugger :yes:

In the CUSTOM\templates\tpl_modules_main_product_image.php file, added the parameter (in bold) from

zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT);

to

zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT, $idPic);

And declared a new var as;

$idPic = 'id="Pic"'

Coming from a non-technical background - not sure if this is the cleanest way of doing it, but it works..

2 Jul 2009, 3:34 PM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to add an id tag to Main Product Image?

erko:

Managed to solve this bugger :yes:

I'd like to see it in operation... What about testing it in full and submitting it as a free Add-on? :clap:

20 years a Zencart User