Creating Lightbox Effects Inside DNN and News Articles 

After my recent change to the new skin design on this site I decided that I need to work on a method to incorporate display for larger images, that under normal situations would break the layout of this site. Most recently I have made a few simple portal configuration changes that allowed me to incorporate a lightbox script, so now I can easily get large images to display like this! In this entry I walk you through the process to obtain the files, load them into DNN, and then to configure Ventrian's News Articles to allow its use.

Obtaining the Script

As I mentioned there are many scripts out there that provide this type of functionality, however, I was directed towards this implementation because it works so well for all browsers. From this site they provide helpful information regarding exactly what you need to do to implement the solution.

Using this in DotNetNuke requires a few modifications from the default so for the time being, simply download each of the files listed on the site and save them to your machine locally. You do NOT need the .css file that is included there.

Preparing the Files for DNN

By default the .js file included in the lightbox script references a loading image and a close image. These files by default have a relative location, I have modified this script for my sites to reflect the FULL URL to the files as they are stored on my site, uploaded from file manager. I reccomend that you change the declarations to mimic the following, replacing mysite.com with your site address and <portalId> with your portal id. We will upload the files to this location a bit later in the process.

var loadingImage = 'http://www.mysite.com/portals/<portalId>/LightBox/loading.gif';	
var closeButton = 'http://www.mysite.com/portals/<portalId>/LightBox/close.gif';

This step completes the changes needed to the default scripts. As I mentioned CSS will be handled in a later step manually.

Upload Files to DNN

In an effort to group files in a logical manner I highly recommend uploading these files to the portal root of your site in their own sub folder. So the first step of the process is to login to your site with Admin permissions and navigate to the File Manager. Create a new folder called LightBox.

Once you have this folder created you will want to upload the following files that were downloaded previously; lightbox.js, overlay.png, loading.gif, close.gif. Be sure that you upload your modified lightbox.js script and not the default one included in the download. Once these files have been uploaded you have now completed the process to install the default files. Next we will take care of the needed CSS elements.

Setting Up the CSS

By default a few CSS classes are presented that include paths to images as well. Again to keep things working nicely with DNN we want to modify this process to ensure that we have correct file paths at all times. Additionally rather than adding yet ANOTHER CSS file to our portal, lets add it to the "Portal" stylesheet that is already included in DotNetNuke.

When logged in as an admin to your site select "Site Settings" from the admin Menu. If you scroll to the bottom you will find the stylesheet editor. Paste the following code into the editor, again replacing mysite.com and <portalId> with the values from your site. These CSS classes are the ones used to style the implementation.

#overlay
{
background-image:
url(http://www.mysite.com.com/portals/<portalId>/LightBox/overlay.png);
} * html #overlay{ background-color: #000; background-color: transparent; background-image:
url(http://www.mysite.com.com/portals/<portalId>/LightBox/blank.gif); filter: progid:DXImageTransform.Microsoft.AlphaImageLoader
(src="http://www.mysite.com.com/portals/<portalId>/LightBox/overlay.png", sizingMethod="scale"); } #lightbox{ background-color:#eee; padding: 10px; border-bottom: 2px solid #666; border-right: 2px solid #666; }

#lightboxDetails
{ font-size: 0.8em; padding-top: 0.4em; } #lightboxCaption{ float: left; } #keyboardMsg{ float: right; } #lightbox img{ border: none; } #overlay img{ border: none; }

These stylesheets were provided by the author of the LightBox script, I have simply listed them here to ensure that readers of this article can fully understand the configuration changes needed. Once these elements have been entered to the Stylesheet editor, click "Save Style Sheet", to commit the changes.

Implementing in Ventrian News Articles

Now that we have loaded all of the needed files we need to simply implement the script in a manner that can make it available for ALL blog entries. To do this we will complete a one-time setup process, then we can simply use the script in the future.

One Time Setup

We need to add a bit of code to the header of the News Article module what includes the reference to the Javascript for the lightbox. We accomplish this by selecting "Settings" from the action menu for the News Articles instance. Once the settings have displayed expand the "Advanced Settings" section and add the following script to the "Header" textbox, be sure to change the values to represent your site url.

<script type="text/javascript" 
src="http://www.mysite.com/portals/<portalId>/LightBox/lightbox.js"> </script>

This will ensure that we have the proper elements loaded at all times.

Using it!

After all of this work we can now get to the fun part! Actually using it, to implement the lightbox solution you simply include a standard link to an image, and add "rel=lightbox" to the url. For example at the top of this article where I have the link "Like This!" that opens to my logo in a lightbox display it was accomplished with the following code.

<a rel="lightbox"
href="http://www.mitchelsellers.com/portals/1/logo-mitchel.png">
like this!
</a>

Summary

With a little bit of setup, and a little bit of education on the side of site administrators it is possible to quickly add lightbox image effects to a DotNetNuke site with specific desires to implement it in the News Articles module for blog/other content. As always, feel free to post comments below or if you are having difficulties implementing this on your site you may post to the forums!

Posted by Mitchel on Friday, September 12, 2008
 

Comments

Good Article! Taking your idea one step further, using one of the Windows Live Writer connector modules, you can automatically make a thumbnail of your image and when clicked opens the origional image in the lightbox without much effort, and it keeps HTML newbies out of the html.
You just insert your image in WLW, resize it to thumbnail size, right-click and select Hyperlink and put 'lightbox' in the rel textbox. The thumb and original will be uploaded to your server when you post the article.

http://www.dignuke.com/Support/tabid/55/forumid/9/view/topic/postid/212/Default.aspx

Thanks,
Mike

By digmike on Friday, September 12, 2008 at 8:57 PM

Great point....I just need to upgrade my copy of News Articles so that I can actually use one of the items that integrate with WLW...

By mitchel.sellers@gmail.com on Friday, September 12, 2008 at 9:29 PM

great article, is it possible to use it in text/html modul? What is different?

By Bernd Mollenhauer on Sunday, September 14, 2008 at 4:49 AM

You sure can!

The process is the same, just add the script element to the header of the Text/HTML module in question, then add the rel="lightbox" to the link!

By mitchel.sellers@gmail.com on Sunday, September 14, 2008 at 9:17 AM

I wonder if there's a way to have this automatically pop up when someone visits a page, ask a question and then record, based on either IP or a cookie what the answer was so that it doesn't pop-up again? I'm thinking along the lines of a e-survey application. It can ask, would you like to take a brief survey? if they answer yes, it closes the window and takes them to the e-survey page. They take the survey and then are sent back to the original page, but without the pop-up coming back on and it doesn't come back on because they've taken the survey, or if they answer No, then it just goes away but knows that they've said No and won't give them the option to take that aprticular survey in the future.

Whew, that was long winded. Or is there something like this out there already?

By Mark on Tuesday, September 16, 2008 at 6:02 AM

Mark,

I'm not aware of any module out there that does this......but I can say that it is only a few hours development at most to do something that simple.

By mitchel.sellers@gmail.com on Tuesday, September 16, 2008 at 6:22 AM

Mitchel,

Since I am not a developer, would you be willing to develop this? If so, let me know and we can talk turkey.

Thanks,

Mark

By Mark on Tuesday, September 16, 2008 at 8:57 AM

Drop me an e-mail and we can talk, msellers@iowacomputergurus.com (But I'm sure you knew that already :) )

By mitchel.sellers@gmail.com on Tuesday, September 16, 2008 at 9:00 AM

In FF 3, the close button doesn't seem to be in the correct spot.

Also, did you look at using jQuery for the thickbox? If so, why not use that?

By erik on Thursday, September 18, 2008 at 4:34 AM

Erik,

I just noticed that as well....hm...

I've also not used jquery before, so I'm not sure how to implement it.

By mitchel.sellers@gmail.com on Thursday, September 18, 2008 at 4:37 AM

For information, I am using [url=http://www.mandeeps.com/]LiveContent from Mandeep[/url] which is working great !!! You can achieve the same, without any code. But I also love this approach, and we will keep the reference !

DV FX

By Declic Video on Sunday, September 28, 2008 at 3:54 AM

We use thickbox in our portfolio and it works great. It's based on jquery. In DNN 4.8.x we have problem with module admin popup menu. The menu cursor/pointer (that little triangle) disappeared - I think there is some collision between dnn and jquery or thickbox. There will be jquery implemented in DNN 5.0 and I hope it will solve the problem - thickbox may contain HTML, iFrame, input forms etc. Examples: http://www.xavio.cz/portfolio.aspx and http://jquery.com/demo/thickbox/

By Tom on Friday, October 10, 2008 at 5:15 PM

I recive an error in the lightbox.js
it says that the method isnt supportet and highlites this:
LightboxOptions = Object.extend({
fileLoadingImage: 'loading.gif',
fileBottomNavCloseImage: 'closelabel.gif',

overlayOpacity: 0.8, // controls transparency of shadow overlay

animate: true, // toggles resizing animations
resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest)

borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable

// When grouping images this is used to write: Image # of #.
// Change it for non-english localization
labelImage: "Image",
labelOf: "of"
}, window.LightboxOptions || {});

Can this be a DNN 5 bug?

By Jhon Wenberg on Tuesday, December 30, 2008 at 3:34 AM

Hi.

Is it possible to animate this as it is originally meant to?

By Jean-Philippe on Tuesday, May 26, 2009 at 1:02 PM

It worked!

Thanks very much for your help, The only thing I see problem is in Firefox it shows close button bit off, Not sure why.

Thanks again.

By Raj Gohil on Saturday, November 21, 2009 at 10:54 AM

It is not working....the image opens the way it opens normally...no light box effect...can you please help?

By navnish on Friday, April 16, 2010 at 1:43 AM
Click here to post a comment

Disclaimer