...

View Full Version : Trying to parse PHP into a Javascript.



Golden_Eagle
10-29-2007, 02:55 AM
Sorry about the vague title, but couldnt think of anything else to call it!

I've found a replacement script I want to use on my site for the Image previews instead of the run of the mill popup.

I need some assistance from someone who doesnt get confused by coding (Not Me, LOL!!)

Firstly, In I found the popup script and looks like this -


<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>

All I wish to do is remove THAT completely and implement what is needed into this -

<a class='expand_a' onclick='imagezoom(this, "http://url.to/full.size.image")'>
<img src="http://url.to/thumbnail.image" class='expand_img' />
</a>

All this is, is a Image viewer that pops up in a new window. I've found a script the uses javascript to just 'expand' the thumbnail (that is the original image, but limited with Width & Height) dynamically on the page. I just need help to implement the strings into the script. But I cant work out how to parse the code correctly, can someone have a go before I give myself headache.

Thanks in advance.
G_E

mic2100
10-29-2007, 10:04 AM
hi

i am not to sure about this but i have create u a PHP print statement that does what you what, if i am wrong PM me and i will sort it for you.


print("<a class='expand_a' onclick='imagezoom(this, \"http://".$_SERVER['HTTP_HOST']."/full.size.image\")'>
<img src='http://".$_SERVER['HTTP_HOST']."/thumbnail.image' class='expand_img' />
</a>");

Golden_Eagle
10-29-2007, 10:43 AM
OK. I'll try to put it into plain english.

Here is my site with a product listed -
http://www.ticklesticks.co.uk/product_info.php?cPath=38&products_id=618

Notice the popup script. The full code that does this is in the product_info.php and is -



<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
<?php
if (tep_not_null($product_info['products_image'])) {
?>


What I want to do is completely replace the 'popup' script with this one -
http://cre.ations.net/blog/post/the-dhtml-thumbnail-zooming-script.

The URL's to the images are linked using -


' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '
For the original thumbnail (It's the main image scaled down using width & height (SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) set in the Admin area.

And the large image inserted into the popup window is
' . tep_image(DIR_WS_IMAGES . $product_info['products_image']) . '

I think, if it was to be entered into the php print statement you made, it would look like


<?php print("<a class='expand_a' onclick='imagezoom(this, \"' . tep_image(DIR_WS_IMAGES . $product_info['products_image']) . '")'>
<img src='' . tep_image(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '' class='expand_img' />'<br>' . TEXT_CLICK_TO_ENLARGE . '</a>"); ?>

But that is just a guess and it's what I'm trying to parse through to the page. (If that makes any sense). I'm no coder and PHP/Javascript's code, although I can suss some parts, confuses the heck out of me sometimes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum