Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 68
  1. #31
    Join Date
    Mar 2009
    Posts
    221
    Plugin Contributions
    1

    Default Re: Additional Image Titles support

    Using the v1.2 files, in additional_images.php, I changed preg_replace back to ereg_replace and image titles have returned.

  2. #32
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    That should teach me to go through the bother of testing even what appears cut & dried... I have duplicated that result. Now to see how preg_replace actually differs from ereg_replace. I couldn't find any difference in the interpreted descriptions for the current case, but there obviously is some difference. The preg version has lots more possibilities listed in the function description. My XAMPP uses PHP 5.2.6, not identical to yours, but ought to be close in treatment of functions.

  3. #33
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    Okay, preg_replace() is not recognizing a . character as something to replace, while ereg_replace() works with the identical pattern definition.

  4. #34
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    This is definitely annoying. From the official PHP site,
    Pattern Syntax > Full stop: "Dot has no special meaning in a character class."
    > Square brackets: "An opening square bracket introduces a character class, terminated by a closing square bracket."

    So what is wrong with
    PHP Code:
    preg_replace('[/\\.-]','_',substr_replace($base_image,'',0,7)) 
    when
    PHP Code:
    ereg_replace('[/\\.-]','_',substr_replace($base_image,'',0,7)) 
    works as planned?

  5. #35
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    After several hours of tutorials, most of which (including the official PHP manual) failed to mention a critical aspect of pattern syntax, I have a working example.
    It takes this
    PHP Code:
    preg_replace('#[/\\\\.-]#','_'
    to replicate the pattern/replacement part of this
    PHP Code:
    ereg_replace('[/\\.-]','_'
    The pattern matching character class [/\\\\.-] or any other pattern statement needs delimiters which can apparently be any of several characters including #, @ and /. Those delimiters go inside the quotes that indicate a text string.
    Next, the manual's statement that a backslash \ inside a character class can be read as a literal by escaping it \\ is incomplete, as it needs to be double-escaped \\\\.
    No doubt there are other subtleties to even these basic aspects of the function which are not mentioned in the tutorials...

  6. #36
    Join Date
    Mar 2009
    Posts
    221
    Plugin Contributions
    1

    Default Re: Additional Image Titles support

    Nice! It's odd though that PHP 5.3 doesn't seem to bark when these delimiters are missing, as your code works in 5.3.

    Just an update...

    In v1.2, I changed ereg_replace back to preg_replace and added your new pattern:

    Code:
    preg_replace('#[/\\\\.-]#','_',
    and Additional Image Titles works great in PHP 5.2.11.
    Last edited by Crunch; 19 Nov 2009 at 06:14 PM.

  7. #37
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    Now that we have this all sorted out, I am following some advice I read and using str_replace instead of preg_replace in the mod, since the replacement is simple enough to allow it. I also like the comprehensibility of
    PHP Code:
    str_replace(array('/','\\','.','-'),'_',substr_replace($base_image,'',0,7)) 
    compared to
    PHP Code:
    preg_replace('#[/\\\\.-]#','_',substr_replace($base_image,'',0,7)) 
    str_replace() is faster, too, though the increase in speed won't be detectable in the present usage.

  8. #38
    Join Date
    Mar 2009
    Posts
    221
    Plugin Contributions
    1

    Default Re: Additional Image Titles support

    I replaced preg_replace with str_replace and it's working fine.
    I can feel your mod getting better, stronger, faster

  9. #39
    Join Date
    Aug 2009
    Location
    Carmi, IL
    Posts
    354
    Plugin Contributions
    0

    Default Re: Additional Image Titles support

    Quote Originally Posted by HelenSama View Post
    This is an update to my other posts in this string. I'm the one, hopefully not the only one, who needs to have the additional image titles from Glenn's mod appear with the larger images in Lightbox/Slimbox.

    I've made some progress, since I am using both the Additional Image Title add-on and the Slimbox add-on, both add-ons have modifications to additional_images.php. At first I could only have one or the other, I've now successfully meshed the modifications so that the additional image titles are appearing and also clicking on larger image brings up the Lightbox so that is working. Here is an example of it, still needs finishing touches but am happy it is working this much: http://peterfasano.com/zen/index.php...&products_id=2

    I still need to have the additional image titles appear with the larger image in the Lightbox instead of where you see the product name in the lower left hand corner. Here is the bottom part of additional_images.php where I have meshed the two modifications together:

    // Link Preparation:
    // bof Zen Lightbox v1.4 aclarke 2007-09-22
    if (ZEN_LIGHTBOX_STATUS == 'true' || FUAL_SLIMBOX == '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="javascriptopupWindow(\\\'' . $large_link . '\\\')">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';

    }
    // eof Zen Lightbox v1.4 aclarke 2007-09-22

    $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="javascriptopupWindow(\''. $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;
    // additional image titles
    $add_img_constant = 'ADDIMG_' . strtoupper(ereg_replace('[/\\.-]','_',substr_replace($base_image,'',0,7)));// if any other characters could be used in filepath, add them to list [ ]
    if (defined($add_img_constant)) {//add text above or below images
    $link = (ADDIMG_TEXT_TOP)? '<h4 class="addImgTitle">' . constant($add_img_constant) . '</h4>' . $link: $link . '<h4 class="addImgTitle">' . constant($add_img_constant) . '</h4>';
    }
    // /additional image titles
    // List Box array generation:
    $list_box_contents[$row][$col] = array('params' => 'class="additionalImages centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => "\n " . $link);
    $col ++;
    if ($col > (IMAGES_AUTO_ADDED -1)) {
    $col = 0;
    $row ++;
    }
    } // end for loop
    } // endif

    ?>

    Does anyone with more php coding experience than I have, have any suggestions? I've tried replacing the constant ($products_name) with the constant ($add_img_constant) but that does not work. (I also have a post in the Commercial Help Needed section but since I haven't gotten a reply resulting in help, I've been working or trying to work on it myself.

    Also in the additional_image_titles_define.php code I downloaded I got an error just after installing that I corrected in my own copy. The error was ..... unexpected } encountered on line #6 --- which is this line --- define ('ADDIMG_TEXT_TOP','true'};//change to false to put text below images

    I change the } to a ) to correct the error.
    Hello,
    I want to use this in the same manner as you do...with Slimbox. I added the above coding and also have this in my image titles:

    define ('ADDIMG_TEXT_TOP',false);//change to false to put text below images
    define ('ADDIMG_IMAGES_LARGE_PRIVATESTOCK_RED_01_LRG_JPG','102 - Naphthol Red');//example title for /images/large/Privatestock_red_01_LRG.jpg
    define ('ADDIMG_IMAGES_LARGE_PRIVATESTOCK_BLUE_02_LRG_JPG','106 - Phthalocyanine Blue');//example title for /images/large/Privatestock_blue_02_LRG.jpg
    ?>


    I only have two images right now to work with until i get this right...anyway...when I click on the image I get a forbidden page telling me I do not have permission to view the file....hummm...could someone please tell em what I am doing wrong here??

    Thanks!
    Pkat

  10. #40
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Additional Image Titles support

    Your best bet may be to ask in the Lightbox/Slimbox dupport thread, as people there will know better how that code works.

 

 
Page 4 of 7 FirstFirst ... 23456 ... LastLast

Similar Threads

  1. Image Titles Support Thread
    By gjh42 in forum All Other Contributions/Addons
    Replies: 155
    Last Post: 9 Sep 2014, 04:51 AM
  2. Additional Image Titles vs Swap_images_mouseover
    By moesoap in forum General Questions
    Replies: 1
    Last Post: 11 May 2012, 04:06 PM
  3. Additional Image Titles mod not working
    By azwli in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 15 Nov 2010, 04:20 AM
  4. Problem integrating additional image titles addon and commercial addon
    By strugglingnovice in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 15 Aug 2010, 03:07 PM
  5. Changing Titles on Sidebox additional pages
    By SaMortensen in forum Addon Sideboxes
    Replies: 4
    Last Post: 7 Feb 2009, 01:34 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