Lightbox JS Tutorial for non-programmers
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
The callbacks file is in the lightbox module that I made to go with greypop. It makes it possible while using lightbox to view images that are on the next and previous pages. For these instructions you don't need it. resizedid is not an inherent gallery function. Did you add the code in theme.inc? That's what makes the $child.resizedid. |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
yea I did. but I just looked thru it and it was missing a curly bracket at the end. So that's probably why $child.resizedId wasnt working. It seems to be working correctly now. Phew! Thanks for all your help lvthunder! Now I have to figure out why lightbox is opening up on album thumbnails and how to get the photo description to show up in lightbox. As I understand, lightbox wont update view count for pics. lvthunder, did you figure out a way to update view count with lightbox enabled? If so, how did you do that? |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
No I haven't figured out a way to do the viewcount other then one method I saw that requires you to hack the core module which I don't want to do. |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
thanks for all your help lvthunder, but Im giving up on lightbox. Ice theme is based off the carbon theme, so I tried implementing lgithbox in that theme to see if it works and I got the same problem. album thumbnails open up with lightbox. I cant figure it out. something to do with the new bit of logic where the |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
The theme.params.frameType is if you use imageframe. What I would do if I were you would be to add some numbers around all those if then statements then you can see what's getting loaded and where in the code it happens. |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
woohoo. thought I'd give it another try and it worked! thanks for all your help lvthunder! You have my deepest gratitude. I put the canContainChildren if within the frametype if and lightbox only works with image thumbnails now. mustve been something with the "capture linkurl" method that was being used before. {if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')} {assign var=frameType value="albumFrame"} {capture assign=linkUrl}{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}{/capture} {else} {assign var=frameType value="itemFrame"} {capture assign=linkUrl} {strip} {if $theme.params.dynamicLinks == 'jump'} {g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"} {else} {g->url params=$theme.pageUrl arg1="itemId=`$child.id`"} {/if} {/strip} {/capture} {/if} <div> {strip} {if isset($theme.params.$frameType) && isset($child.thumbnail)} {g->container type="imageframe.ImageFrame" frame=$theme.params.$frameType width=$child.thumbnail.width height=$child.thumbnail.height} <a href="{$linkUrl}" alt="{$title}" title="{$title}"> {g->image id="%ID%" item=$child image=$child.thumbnail class="%CLASS% giThumbnail"} </a> {/g->container} {elseif isset($child.thumbnail)} <a href="{$linkUrl}" alt="{$title}" title="{$title}"> {g->image item=$child image=$child.thumbnail class="giThumbnailIce"} </a> {else} <a href="{$linkUrl}" class="giMissingThumbnail"> {g->text text="no thumbnail"} </a> {/if} {/strip} </div> My modified code to make lightbox work {if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')} {assign var=frameType value="albumFrame"} {else} {assign var=frameType value="itemFrame"} {/if} <div> {strip} {if isset($theme.params.$frameType) && isset($child.thumbnail)} {g->container type="imageframe.ImageFrame" frame=$theme.params.$frameType width=$child.thumbnail.width height=$child.thumbnail.height} {if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')} <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}" alt="{$title}" title="{$title}"> {else} {if $theme.params.dynamicLinks == 'jump'} <a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.resizedId`"}" alt="{$title}" title="{$title}" rel="lightbox[photos]"> {else} <a href="{g->url params=$theme.pageUrl arg1="itemId=`$child.id`"}" alt="{$title}" title="{$title}" rel="lightbox[photos]"> {/if} {/if} {g->image id="%ID%" item=$child image=$child.thumbnail class="%CLASS% giThumbnail"} </a> {/g->container} {elseif isset($child.thumbnail)} {if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')} <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}" alt="{$title}" title="{$title}"> {else} {if $theme.params.dynamicLinks == 'jump'} <a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.resizedId`"}" alt="{$title}" title="{$title}" rel="lightbox[photos]"> {else} <a href="{g->url params=$theme.pageUrl arg1="itemId=`$child.id`"}" alt="{$title}" title="{$title}" rel="lightbox[photos]"> {/if} {/if} {g->image item=$child image=$child.thumbnail class="giThumbnailIce"} </a> {else} <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}" class="giMissingThumbnail"> {g->text text="no thumbnail"} </a> {/if} {/strip} </div> |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
couple things I wanna add now.... I'd appreciate any thoughts on these, lvthunder. |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
1 and 2. Take a look at my lightbox links in greypop. If I remember correctly everything you want in lightbox goes in the description. Just beware that you can't have any apostrophes or it will break. Greypop tests for this and replaces the ' with an equivalent. |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
do I need to use your version of lightbox.js also? I did a compare and there are lots of differences between the one that comes with greypop and the latest one that im using. And do I put the entire lightbox folder inside gallery/modules folder? All I have to do is that and change the paths to lightbox.css, lightbox.js, etc in theme.tpl head and everything else the same? Talking about that, I didnt see greypop's theme.tpl refer to the lightbox .css and .js files. Why is that? |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Well you can do one of two things. Either use the one with the greypop theme (it's an older version) that I modified so that if javascript is disabled it will show the photo page instead of just the image. If you do that you need to modify your links to look close to what I have in greypop. If you want to use your version just replace the js file with yours. If you do this you need to change the links in before.tpl and after.tpl Yes, put the entire lightbox folder inside gallery/modules. You can either leave the stuff you have in theme.tpl or add this to the |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
ok so i moved greypop's lightbox in my modules folder. activated it in site admin. changed my links that call lightbox in childs.tpl from <a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.resizedId`"}" alt="View Slideshow" title='{$title}<br><a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">View Photo Page</a>' rel="lightbox[photos]"></a> to <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}" rev="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.resizedId`"}" alt="View Slideshow" title='{$title}<br><a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">View Photo Page</a>' rel="lightbox[photos]"></a> added this to top and bottom of album.tpl {assign var="total" value=0} {assign var="first" value=0} {assign var="last" value=0} {math equation="x * y" x=$theme.params.columns y=$theme.params.rows assign=total} {if ($theme.currentPage > 1)} {math equation="(x - 1) * y + 1" x=$theme.currentPage y=$total assign=first} {g->block type="lightbox.Before" class="Peers" windowSize=$theme.childCount first=$first} {/if} {if ($theme.currentPage < $theme.totalPages)} {math equation="x * y" x=$theme.currentPage y=$total assign=last} {g->block type="lightbox.After" class="Peers" windowSize=$theme.childCount last=$last} {/if} took out the links to lightbox .js and .css from theme.tpl's head since you have those covered in Preloads.inc But now links open up photo page instead of lightbox. Thought it might be because in the ice theme album.tpl is actually divided up - it calls childs.tpl - which is where the links to lightbox is. So i moved the code from album.tpl to childs.tpl. But the same thing. Wait a sec. Am I supposed to move After.tpl, before,tpl, head.tpl and blocks.inc.old to modules/core/templates/blocks/local/? |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
lvthunder, i found this old post by you in this thread. where you suggest creating peerlist.tpl. Can I follow that method and use the latest version lightbox I was using before? |
|
aharami
Joined: 2007-04-16
Posts: 47 |
![]() |
nevermind. it is working now. I forgot to add the |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
The only thing now is don't have an ' in your titles. If you do it will break things. If you want ' in your titles there is some code in albumlight.tpl that changes them to something that doesn't break. |
|
tbesek
Joined: 2007-04-14
Posts: 16 |
![]() |
I just applied this tutorial to my Matrix Themed Gallery. I am running Gallery 2.2.2. Any ideas? Here's the URL: |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Your URL just gets me to a login place, but generally when you don't have a close button it's the paths the in css file that's the cause. By the way you can click below the lightbox and it will close. |
|
mrmax182
![]()
Joined: 2007-11-18
Posts: 1 |
![]() |
I cant get it to work on gallery 2.2.3 looks like the matrix theme code has changed a bit, anyone knows where to find a updated tutorial for matrix on 2.2.3?? |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
mrmax182 wrote:
I cant get it to work on gallery 2.2.3 looks like the matrix theme code has changed a bit, anyone knows where to find a updated tutorial for matrix on 2.2.3?? What's not working? You need to provide more detail then that. If you don't want to mess with it try out the greypop theme. It has lightbox integrated and it looks close to matrix. You might want to change the colors because greypop is a dark grey theme. |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
i have the same problem of tbesek i dont have the close button, i tried everything .. but nothing seems to work .. this is my gallery http://panel2.powered-hosting.com:81/whiteisfashion.com/gallery2/main.php?g2_itemId=14 anybody knows how can i fix it ? |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
You need to check the path to the image of the closed button. Off the top of my head I can't remember if that's in the js file or the css file. |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
is in the .js file .. but the problem doesn't seen to be there ! i already tryed with : "../../gallery2/lightbox/images/closelabel.gif" "../gallery2/lightbox/images/closelabel.gif" "the full direction" even i tryed to put the close image in the same folder "closelabel.gif" but until now nothing seems to work |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Try the full path to the image starting with http:// |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
i tryed too the full path between quotes "http://panel2.powered-hosting.com:81/whiteisfashion.com/gallery2/lightbox/images/closelabel.gif" i dont know where is the problem :/ |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Maybe it's the nonstandard port number, but that path looks odd. What's the path to your gallery? |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
the "odd" url is because i dont have my ".com" yet .. the path to my gallery index is http://panel2.powered-hosting.com:81/whiteisfashion.com/gallery2/ i even tryed with http://i18.tinypic.com/6obqhb5.gif .. and it doesnt work either anyway thx for your help |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
snap90210 wrote:
the "odd" url is because i dont have my ".com" yet .. Your loading all the javascript multiple times from multiple locations so I'm guessing which one loads last is changing the path. |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
i put my lightbox folder in /gallery2 .. so you say all the javascript is loading from multiples locations ? how can i fix that ? thx in advance |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Here's the head part of your code. <html> <head> <link rel="stylesheet" href="/gallery2/lightbox/css/lightbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="/gallery2/lightbox/js/prototype.js"></script> <script type="text/javascript" src="/gallery2/lightbox/js/lightbox.js"></script> <script type="text/javascript" src="/gallery2/lightbox/js/efx/scriptaculous.js"></script> <link rel="stylesheet" type="text/css" href="main.php?g2_view=imageframe.CSS&g2_frames=none"/> <link rel="stylesheet" type="text/css" href="modules/core/data/gallery.css"/> <link rel="stylesheet" type="text/css" href="modules/rating/rating.css"/> <link rel="stylesheet" type="text/css" href="modules/icons/iconpacks/silk/icons.css"/> <link rel="stylesheet" type="text/css" href="modules/rating/rating.css"/> <script type="text/javascript" src="lib/yui/yahoo-min.js"></script> <script type="text/javascript" src="lib/yui/connection-min.js"></script> <script type="text/javascript" src="modules/rating/rating.js"></script> <script type="text/javascript" src="lib/yui/yahoo-min.js"></script> <script type="text/javascript" src="lib/yui/connection-min.js"></script> <script type="text/javascript" src="modules/rating/rating.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Prueba 1</title> <link rel="stylesheet" type="text/css" href="themes/matrix/theme.css"/> </head> <link rel="stylesheet" type="text/css" href="/public_html/gallery2/lightbox/css/lightbox.css" /> <script type="text/javascript" src="/public_html/gallery2/lightbox/js/prototype.js"></script> <script type="text/javascript" src="/public_html/gallery2/js/lightbox.js"></script> <script type="text/javascript" src="/public_html/gallery2/lightbox/js/scriptaculous.js?load=effects"></script> <link rel="stylesheet" type="text/css" media="screen" href="themes/matrix/includes/css/lightbox.css" /> <script type="text/javascript" src="themes/matrix/includes//js/prototype.js"></script> <script type="text/javascript" src="themes/matrix/includes/js/effects.js"></script> <script type="text/javascript" src="themes/matrix/includes/js/lightbox.js"></script> <body class="gallery"> So if you don't have a lightbox module or g2 embedded you need to look at theme.tpl to remove the duplicates. |
|
snap90210
Joined: 2007-12-19
Posts: 6 |
![]() |
Thx ! now it works |
|
appelm
Joined: 2008-01-02
Posts: 20 |
![]() |
On the lightbox forum I found an interesting update written by Justin Barkhuff that adds an auto-slideshow and prev-next links to the caption area. You can find it here: I've been using greypop for my gallery for a while and am quite happy with it. |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
From what I can tell that is a pretty major mod to lightbox so the mod I did to greypop won't work unless someone who knows a whole lot more about javascript then I do can get it to work. If you don't care if just the picture shows if someone turns off Javascript you need to modify albumlight.tpl, before.tpl, and after.tpl and change the links back to normal lightbox links. |
|
appelm
Joined: 2008-01-02
Posts: 20 |
![]() |
lvthunder wrote:
From what I can tell that is a pretty major mod to lightbox so the mod I did to greypop won't work unless someone who knows a whole lot more about javascript then I do can get it to work. If you don't care if just the picture shows if someone turns off Javascript you need to modify albumlight.tpl, before.tpl, and after.tpl and change the links back to normal lightbox links. I'm surprised it would be all that hard. Isn't most of the lightbox code you used fairly independant of gallery. I would have thought it would just be a few lines of code that have to change. Did you have to change much lightbox to get it to work in greypop? I was going to give this a try myself but your comment is giving me pause! |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
No what I'm saying is that the lightbox slideshow folks changed a lot. The only thing I changed in lightbox is to make it look for the link to the picture in the rel tag instead of the href tag. If they left that part intact it won't be a hard change. I just don't know very much Javascript at all. I didn't even create the change to the js file. I found it here on the forums. |
|
appelm
Joined: 2008-01-02
Posts: 20 |
![]() |
ok.. I expect we can get it to work. Seems to me this would be a pretty sweet enhancement to greypop or other themes. |
|
appelm
Joined: 2008-01-02
Posts: 20 |
![]() |
Got it to work! I will clean it up and then upload the files. |
|
appelm
Joined: 2008-01-02
Posts: 20 |
![]() |
I posted the lightbox slideshow files in the main greypop thread here. |
|
Cammie895
Joined: 2008-01-14
Posts: 2 |
![]() |
snap90210 wrote:
is in the .js file .. but the problem doesn't seen to be there ! I'm having the same problem and haven't had any luck fixing it. **edit** Nevermind...I finally figured it out. I was overlooking a second js file in the image folder. : ) |
|
acysos
![]()
Joined: 2008-07-28
Posts: 1 |
![]() |
Hello, I have an error with the gallery 2.2.5 and lightbox 2.0.4. The lightbox doesn't work because it need the builder.js. The solution is add the line <script type="text/javascript" src="/path/to/lightbox/js/builder.js"></script> before the load of lightbox.js in the head of the theme.tpl. Greetings |
|
nifer
Joined: 2008-10-05
Posts: 1 |
![]() |
misterlib wrote:
I had the same question. I have gone through the tutorial to the point when you need to change these lines in lightbox.js: Hi Has anyone resolved this problem. I'm using Lightbox v2.04 and Gallery 2.2. Or did you just go back to the old version? Thanks J. |
|
lvthunder
Joined: 2003-09-12
Posts: 808 |
![]() |
Basically what you have to do is look at the unmodified old version and find the same spot in the new script. I'm using a pretty hevyally modified version now that I can't be much help. My version uses jquery instead of the prototype and scriptilous. |
|
mattpesquet
Joined: 2010-06-20
Posts: 8 |
![]() |
hi all here is the link to my gallery i followed all the instruction to modify theme.inc, theme.tpl, album.tpl files...still not working for me The first problem was to find in the theme.inc that line Quote:
$theme['columnWidthPct'] = floor(100 / $params['columns']); that doesnt exist, then i tried to find by myself the better place to past the piece of code. link to my theme.inc modified file : http://mattpesquet.com/photo/themes/siriux/theme.inc Same problem for album.tpl, cant find the piece of code to replace. then i replaced Quote:
<div class="gallery-thumb"> with the piece of code provided in the first post. link to my modified album.tpl : http://mattpesquet.com/photo/themes/siriux/templates/local/album.tpl i hope someone will help me ! |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
Either changes haven't been made to your tpl files or more likely your server is processing them in some fashion and not serving them up as text files. Either way, from looking at the source of one of your pages, you didn't use rel="lightbox" but rather used rel="Lightbox" try lightbox (lowercase) Though that probably won't fix it as it appears the change isn't made to the right section in album.tpl as rel="lightbox is set on albums (thumbs) and not photo (thumbs) http://mattpesquet.com/photo/main.php Can you zip up your siriux theme and either post it or post a link to it. |
|
mattpesquet
Joined: 2010-06-20
Posts: 8 |
![]() |
thanks for your reply nivekiam, i would like to remove the action box in the album page (under the bottom ligne) and maybe stick there the search field. thank you |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
mattpesquet
Joined: 2010-06-20
Posts: 8 |
![]() |
yes sorry to hijack this thread, i worked more on my side and my questions are a bit different now, i started a new thread with them. |
|