Jmonks's Lightbox Mod [Moved from Thickbox mod thread[

Hello guys,



I have spending today triying implementing LightBox instead of Thickbox…

and works properly!!! :smiley:



You can find more info about Lightbox on

[URL=“http://www.huddletogether.com/projects/lightbox2/#example”]http://www.huddletogether.com/projects/lightbox2/#example[/URL]



Just to implement this, you have to:



(previously you need to download it from [URL=“http://www.huddletogether.com/projects/lightbox2/releases/lightbox2.03.3.zip”]http://www.huddletogether.com/projects/lightbox2/releases/lightbox2.03.3.zip[/URL]

and put onto …classes/script and skin/xxx/customer/)



In customer/index.tpl add this code:

[quote]


{include file="meta.tpl"}
[COLOR="Red"]{* Lightbox modification *}
{if $target == 'products'} {* thanks to snorocket, to avoid an error during checkout process *}




{/if}[/COLOR]
{* end modf *}

{strip}

{if $page_title}
{$page_title}
{else}
[/quote]

In product_pages/product_options.tpl add this code:
[quote]
{foreach from=$product.option_image_pairs item="imag" name="ii" key="_key"}
pr_i[{$id}][{$smarty.foreach.ii.iteration}-1] = {$ldelim}
'image_id': '{$imag.image_id}',
'detailed_id': '{$imag.detailed_id}',
[I][COLOR="Red"] 'detailed_id2': '{$imag.detailed.image_path}',[/COLOR][/I]
'options': '{$imag.options}'
{$rdelim};
[/quote]

In classes/scripts/exceptions.js add the code in red:
Under **************images**************

[quote]
new_ref[id] = "javascript:fn_open_popup_image('"+image_index+"?object_type=detailed&image_id="+pr_i[id][row]['detailed_id']+"&window=popup', "+pr_i[id][row]['detailed']['image_x']+", "+pr_i[id][row]['detailed']['image_y']+"+ 30);"
[/quote]
With
[quote]
function fn_change_image(id, row)
{
if (pr_i[id][row]['detailed_id'] != '' && pr_i[id][row]['detailed_id'] != '0') {
[COLOR="Red"] new_ref[id] = ""+pr_i[id][row]['detailed2']+""[/COLOR]
if (document.getElementById('detailed_box_' + id)) {
document.getElementById('detailed_box_' + id).style.display = "block";
}
if (document.getElementById('detailed_href1_' + id)) {
document.getElementById('detailed_href1_' + id).href = new_ref[id];

[/quote]

In common_templates/images.tpl this is the full file if you want to use it, or sort the bits in red:

[quote]
{* $Id: image.tpl 4188 2007-10-08 08:01:09Z imac $ *}
{strip}

{if $settings.Addons.seo == 'Y'}
{assign var="image_location" value="$current_location/"}
{/if}
{if $show_detailed_link && $images.detailed_id}
[COLOR="Red"] {*assign var="detailed_href" value="javascript:fn_open_popup_image('$image_location$image_index?object_type=detailed&image_id=`$images.detailed_id`&window=popup', `$images.detailed.image_x`+84, `$images.detailed.image_y` + 140);"*}
{if $settings.General.images_location == "database"}
{assign var="detailed_href" value="$image_index?object_type=detailed&image_id=`$images.detailed_id`"}
{else}
{assign var="detailed_href" value="`$images.detailed.image_path`"}
{/if}
[/COLOR]
{/if}

{if !$image_width}
{if $images.icon.image_x}
{assign var="image_width" value=$images.icon.image_x}
{/if}
{if $images.icon.image_y}
{assign var="image_height" value=$images.icon.image_y}
{/if}
{else}
{if $images.icon.image_x && $images.icon.image_y}
{math equation="new_x * y / x" new_x=$image_width x=$images.icon.image_x y=$images.icon.image_y format="%d" assign="image_height"}
{/if}
{/if}

{if $show_thumbnail == 'Y' && $image_width && $images.image_id}
{assign var='object_type' value=$object_type|default:'product'}
{assign var='icon_image_path' value="$image_index?$mode_name=show_thumbnail&image_id=`$images.image_id`&object_type=$object_type&width=$image_width"}
{else}
{assign var='icon_image_path' value=$images.icon.image_path}
{/if}

{if $images.icon.image_type != 'application/x-shockwave-flash'}
{if $detailed_href}
[COLOR="Red"] [/COLOR]
{/if}

{if $obj_id && !$no_ids}


{/if}
{$images.icon.alt|escape:html}
{if $detailed_href}

{/if}
{else}





{if $flash_vars}

{/if}


{/if}

{if $show_detailed_link}


[COLOR="Red"]
{$lang.view_larger_image}
{* VERIFY THAT "lang.view_larger_image" doesn't have any space *}
[/COLOR]


{/if}

{/strip}

{if $obj_id && !$no_ids}

{/if}
[/quote]

Check the CSS and make sure the referenced prev.gif and next.gif files are in the right location. Also, make sure the loading.gif and close.gif files as referenced near the top of the lightbox.js file are in the right location.

After those modifications, results are on image1.jpg and image2.jpg...
To avoid any ofense I set some censored on that images :rolleyes:

hope this helps...

Jmonk

image2.jpg

image1.jpg

[quote name=‘jmonk’]

To avoid any ofense I set some censored on that images :rolleyes: [/quote]



Takes the fun out of everything! hehe



I’ll try to implement this when I get back home if it works I owe you a “thank you” post :wink:

works great Jmonk only correction is in {if $show_detailed_link} the language varible {$lang.view_larger_image} has a space in it that makes the show detailed image link to be blank, remove the space and it works great, Thank You for your time and contribution to making this modification work, it’s great when people freely contribute to the community instead of taking a previous existing mod and trying to sell it, this LightBox mod works and looks alot better then ThickBox and it works in IE6, IE7 and FF, Thanks again - sno

Thanks JMonk

JMonk,



Could you start a new thread for lightbox? It would be nice not to have to go ten pages into the thickbox thread to find it.



Just a thought.

just realized this mod causes errors during checkout, easy solution though, just add the {if} condition as shown below, this allows the lightbox scripts to execute only on the product pages:

```php

[color=red]{if $target == ‘products’}[/color]





[color=red]{/if}[/color] ```

Good night,


[quote name=‘snorocket’]works great Jmonk only correction is in {if $show_detailed_link} the language varible {$lang.view_larger_image} has a space in it that makes the show detailed image link to be blank, remove the space and it works great, Thank You for your time and contribution to making this modification work, it’s great when people freely contribute to the community instead of taking a previous existing mod and trying to sell it, this LightBox mod works and looks alot better then ThickBox and it works in IE6, IE7 and FF, Thanks again - sno[/QUOTE]



Thanks Snorocket, but in my original there is no space there, don’t know why but when publish it, appears an space… if I try to edit there is no space to delete. I put a note about that on this post and the new one I’ve created few moments ago …


[quote name=‘tletourneau’]JMonk,



Could you start a new thread for lightbox? It would be nice not to have to go ten pages into the thickbox thread to find it.



Just a thought.[/QUOTE]



Sorry, forgot to create new post, but noticed that moderator has moved to new one… I suppose it was Jesse… THanks a lot… :wink:

Also created new one about another good implementation


[quote name=‘snorocket’]just realized this mod causes errors during checkout, easy solution though, just add the {if} condition as shown below, this allows the lightbox scripts to execute only on the product pages:

```php

[color=red]{if $target == ‘products’}[/color]





[color=red]{/if}[/color] ```[/QUOTE]

Great!!! thanks a lot snorocket... Already modify this post and update with your advice and included on the new post of Greybox too...

:D

thanks again

Jmonk

OK, I’m a little confused. In the following section do we add or replace code? The instructions say add but the example looks like a replace. What am I not getting?





snip…

[quote name=‘jmonk’]

In classes/scripts/exceptions.js add the code in red:

Under images


new_ref[id] = "javascript:fn_open_popup_image('"+image_index+"?o bject_type=detailed&image_id="+pr_i[id][row]['detailed_id']+"&window=popup', "+pr_i[id][row]['detailed']['image_x']+", "+pr_i[id][row]['detailed']['image_y']+"+ 30);"




With


function fn_change_image(id, row)
{
if (pr_i[id][row]['detailed_id'] != '' && pr_i[id][row]['detailed_id'] != '0') {
[COLOR="Red"]new_ref[id] = ""+pr_i[id][row]['detailed2']+""[/COLOR]
if (document.getElementById('detailed_box_' + id)) {
document.getElementById('detailed_box_' + id).style.display = "block";
}
if (document.getElementById('detailed_href1_' + id)) {
document.getElementById('detailed_href1_' + id).href = new_ref[id];


[/QUOTE]

…end snip

Hi Tom



You need to replace that line with the one in red.

Hello Zardos,



Thanks! One last question, I downloaded the zip file, what files need to be put where? Do I need to copy the index.html file that was in there to my server?



I guess I’m tired today, for some reason I can’t seem to figure this out.

Hi Tom



No, you need to edit your existing index.tpl and add the code in RED, do the same with the rest of the files.



You need to place the lightbox scripts download in classes/scripts/xxxxxxx.js place the images in your_skin/customer/images and add the lightbox.css to your_skin/customer.



Then:


Zardos,



Thanks for the help & clarification! I got it working and it’s very nice!



JMonk,



Great job! Thank you very much!

just noticed if you have the comments and reviews addon enabled this mod jacks it all up when you try to submit a review, it will take someone knowledgeable in javascript to fix this one…

along with the send to friend addon enabled it would just return with a popup box filled with errors, if anybody knows a fix for this, please post.



I have the send to friend feature disabled for now.

Hi, anybody can help me to process this on 1.3.4SP3 ? Bcoz I can’t find classes folder under /skins/default_blue/customer, I found the exceptions.js under product_pages folder.



But I still can’t find the line “**images



Anyone can help me ? Very appreciate ! many thanks.

classes folder is in root folder not the skins folder.

I’ve checked the root folder, but no exceptions.js under classes folder, am I wrong ?

ROOT/classes/scripts/exceptions.js

Hi Jmonk/All,



What versions of CS-Cart does this work with? I am trying to install on CS-Cart 1.3.3 and CS-Cart 1.3.4sp3 and neither have a “scripts” directory located under ROOT/classes. In addition, 1.3.3 does not have an images.tpl file. Please advise… Thanks!

1.3.5+ however it conflicts with the news, send to friend, reviews addons…