Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trying to parse PHP into a Javascript.

    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 -

    Code:
    <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 -
    Code:
    <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

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    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.

    PHP Code:
    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>"
    ); 

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK. I'll try to put it into plain english.

    Here is my site with a product listed -
    http://www.ticklesticks.co.uk/produc...roducts_id=618

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

    Code:
    <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-...zooming-script.

    The URL's to the images are linked using -
    Code:
    ' . 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
    Code:
    ' . 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
    Code:
    <?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.
    Last edited by Golden_Eagle; 10-29-2007 at 11:47 AM.


  •  

    Posting Permissions

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