Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2007
    Posts
    58
    Plugin Contributions
    0

    Default JS Error in additional images with Lightbox and ImageHandler2

    Hi,

    Not sure exactly where this posts belongs, but it is about problems with additional images, so here goes.

    I'm actually writing with both a problem and a solution ... first time I've actually provided anything useful on this forum . It's just not the greatest solution in the world and I'm hoping that a guru out there might be able to help.

    I've had problems with additional images in which I always receive an error message saying:

    missing ) after argument list in index.php line xxx
    At first I thought the problem was something to do with Image Handler 2 so I raised this question in that forum. I know that edwinlloyd reported the same problem there.

    Now I know that it's got nothing to do with IH2. Instead it seems to be in /includes/modules/additional_images.php. I've pasted the excerpt below.

    PHP Code:
    // Link Preparation:
    $script_link '<script language="javascript" type="text/javascript"><!--' "\n" 'document.write(\'' . ($flag_display_large '<a href="javascript:popupWindow(\\\'' $large_link '\\\')">' $thumb_slashes '<br />' TEXT_CLICK_TO_ENLARGE '</a>' $thumb_slashes) . '\');' "\n" '//--></script>';

    $noscript_link '<noscript>' . ($flag_display_large '<a href="' zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL'pID=' $_GET['products_id'] . '&pic=' $i '&products_image_large_additional=' $products_image_large) . '" target="_blank">' $thumb_regular '<br /><span class="imgLinkAdditional">' TEXT_CLICK_TO_ENLARGE '</span></a>' $thumb_regular ) . '</noscript>';

    //$alternate_link = '<a href="' . $products_image_large . '" onclick="javascript:popupWindow(\''. $large_link . '\') return false;" title="' . $products_name . '" target="_blank">' . $thumb_regular . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>';

    $link $script_link "\n " $noscript_link;
    // $link = $alternate_link; 
    When I remove the comments in front of the $alternate_link, the additional images display. I don't understand the $script_link and $no_script_link enough to find out what the problem is. Can anyone help? Presumably there was a good reason for not using the "alternate" version in the first place, so I'd like to see the intended version working.

    Thanks,

    Possum.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: JS Error due to ' in additional image descriptions

    <script> tags are used to process the javascript popups.
    <noscript> tags are used to handle cases where javascript is disabled.

    The $alternate_link uses no javascript to do a popup, and instead opens a different browser session with all its headers and other junk.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2007
    Posts
    58
    Plugin Contributions
    0

    Default Re: JS Error due to ' in additional image descriptions

    Thanks Doc,

    Honoured to have you on the case!

    I have experimented with enabling/disabling Javascript, as well as with the use of the alternate link and this is what I've found:

    I get one "missing ) after argument list" for every additional image I have whenever I use Javascript. Without Javascript it works OK (although obviously without the niceties of the javascript). This happens independent of whether I have the Zen Lightbox functionality turned on or off. (It happened before I installed Lighbox as well).

    Here's the code that is giving me grief:
    Code:
    if (ZEN_LIGHTBOX_STATUS == 'true') {
    $script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="' . zen_lightbox($products_image_large, addslashes($products_name), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT) . '" rel="lightbox[gallery]" title="' . addslashes($products_name) . '">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';
    } else {
    $script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="javascript:popupWindow(\\\'' . $large_link . '\\\')">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';
    }
    and here's a link to the example where it's happening. (You can see the small dotted vertical lines separating where the images are supposed to be:

    http://test.possumbooks.com/index.ph...roducts_id=232


    Finally, here's an excerpt from the resulting page source code that shows what the final script looked like:

    Code:
    <script language="javascript" type="text/javascript"><!--
    document.write('<a href="javascript:popupWindow(\'http://test.possumbooks.com/index.php?main_page=popup_image_additional&amp;pID=232&amp;pic=0&amp;products_image_large_additional=images/Illustrated Fairytales_01.jpg\')"><img src="bmz_cache/e/ef2387c104eb5dbe00217b48e5e57cd2.image.100x63.jpg" alt="Illustrated Fairy Tales" title=" Illustrated Fairy Tales " width="100" height="63" style="position:relative" onmouseover="showtrail('bmz_cache/d/d75abaa72c100a305044756fcc6d7193.image.180x113.jpg','Illustrated Fairy Tales',100,63,180,113,this,0,0,100,63);" onmouseout="hidetrail();"  /><br />larger image</a>');
    //--></script>
          <noscript><a href="http://test.possumbooks.com/index.php?main_page=popup_image_additional&amp;pID=232&amp;pic=0&amp;products_image_large_additional=images/Illustrated Fairytales_01.jpg" target="_blank"><img src="bmz_cache/e/ef2387c104eb5dbe00217b48e5e57cd2.image.100x63.jpg" alt="Illustrated Fairy Tales" title=" Illustrated Fairy Tales " width="100" height="63" style="position:relative" onmouseover="showtrail('bmz_cache/d/d75abaa72c100a305044756fcc6d7193.image.180x113.jpg','Illustrated Fairy Tales',100,63,180,113,this,0,0,100,63);" onmouseout="hidetrail();"  /><br /><span class="imgLinkAdditional">larger image</span></a></noscript></div></td>
    Can you see any errors in there?

    Really appreciate your thoughts on this one.

    Possum.

  4. #4
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: JS Error due to ' in additional image descriptions

    Your lightbox code in conjunction with Image Handler seem to not be escaping ' marks properly.

    document.write('<a href="javascriptopupWindow(\'http://test.possumbooks.com/index.php?main_page=popup_image_additional&amp;pID=232&amp;pic=0&amp;products_im age_large_additional=images/Illustrated Fairytales_01.jpg\')"><img src="bmz_cache/e/ef2387c104eb5dbe00217b48e5e57cd2.image.100x63.jpg" alt="Illustrated Fairy Tales" title=" Illustrated Fairy Tales " width="100" height="63" style="position:relative" onmouseover="showtrail('bmz_cache/d/d75abaa72c100a305044756fcc6d7193.image.180x113.jpg','Illustrated Fairy Tales',100,63,180,113,this,0,0,100,63);" onmouseout="hidetrail();" /><br />larger image</a>');

    The whole document.write line is inside single quotes, which means any use of single-quotes in the rest of the document.write command must be escaped.

    ie: good escaping:
    Code:
    javascript:popupWindow(\'http://test.possumbo
    ie: bad escaping:
    Code:
    onmouseover="showtrail('bmz_cache/d/d75abaa72c100a305044756fcc6d7193.image.180x113.jpg','Illustrated Fairy Tales',
    One or both of those mods isn't doing everything correctly.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Sep 2007
    Posts
    58
    Plugin Contributions
    0

    Default Re: JS Error in additional images with Lightbox and ImageHandler2

    Hi again,

    Just thought I'd write back to say thanks to Dr Byte for his help and to let everyone know how this was resolved.

    The problem was apparently in includes/classes/bmz_image_handler_class.php

    Line 702 should read

    Code:
     return $parameters . 'style="position:relative" onmouseover="showtrail(' . "\'$products_image_zoom\',\'$alt\',$width,$height,$zoomwidth,$zoomheight,this," . $this->zoom['startx'].','.$this->zoom['starty'].','.$this->zoom['width'].','.$this->zoom['height'].');" onmouseout="hidetrail();" ';
    Note the extra backslashes around $products_image_zoom and $alt

    Thanks again. The lightbox effect looks fab.

    Possum.

  6. #6
    Join Date
    Sep 2007
    Posts
    58
    Plugin Contributions
    0

    Default Re: JS Error in additional images with Lightbox and ImageHandler2

    Hi,

    Possum again. Just writing back to say ignore my previous message. The real solution is here ...

    http://www.zen-cart.com/forum/showpo...&postcount=986

    My solution meant that the additional images worked but it broke the hover-zoom effect. Jettrue's conditional solution works with both.

    Possum

 

 

Similar Threads

  1. Additional images and Zen Lightbox
    By ianhg in forum All Other Contributions/Addons
    Replies: 9
    Last Post: 15 Oct 2014, 12:37 AM
  2. Additional images and Zen Lightbox
    By ianhg in forum General Questions
    Replies: 1
    Last Post: 6 Nov 2013, 05:30 PM
  3. v139h lightbox and IH2 - additional image not working in the lightbox
    By kitcorsa in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 2 Aug 2013, 10:45 AM
  4. Lightbox not working with additional images on new template!
    By wildfashions in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 30 Nov 2008, 05:16 PM
  5. lightbox and additional images
    By digz in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 13 Oct 2007, 06:21 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR