Using GreyBox and LightBox with mojoPortal

Update March 30, 2011: As of version 2.3.6.4, mojoPortal changed from GreyBox to Colorbox, these instructions are no longer relevant.

Using GreyBox

mojoPortal comes bundled with Greybox which is a great in-site pop-up utility that can be used for displaying images and even other webpages in an in-site pop-up. It is used in the image galleries, help system, skin previewer, and a lot of other areas of mojoPortal

You might be interested to know that you can use GreyBox in your mojoPortal site without utilizing the ImageGallery or other features of mojoPortal that use it. Simply add the rel="gb_image[]" or rel="gb_page[]" property to any link and the the link target will open in a GreyBox pop-up window.

For example, clicking the thumbnail below will open the full-size image in a GreyBox window:

<a href="/Data/Sites/1/blogdata/lightbox-dsc06798-full.jpg" rel="gb_image[]" title="4th &amp; Broadway, San Diego, CA (C) Joe Davis">
	<img alt="" src="/Data/Sites/1/blogdata/lightbox-dsc06798-thumb.jpg" width="133" height="100" />
</a>

4th & Broadway, San Diego, CA (C) Joe Davis

The link below will open the mojoPortal website in a fullscreen GreyBox window:

<a href="http://www.mojoportal.com" rel="gb_page_fs[]" title="mojoPortal, The World's Greatest .NET CMS">Open mojoPortal in GreyBox</a>

Open mojoPortal in GreyBox

There are a lot of other neat things you can do with GreyBox that you may not be aware of so I recommend checking out the GreyBox website for more helpful hints.

 

Using LightBox with MojoPortal

Some people like other utilities like LightBox (the jQuery version), for example. I will demonstrate to you how to use LightBox alongside GreyBox with mojoPortal.

The Setup

  1. The first step to using LightBox is to download the jQuery-LightBox release from http://leandrovieira.com/projects/jquery/lightbox/. Once you have downloaded the release, extract it to your local hard drive.
  2. Using your favorite FTP client (mine is FileZilla):
    1. Create a new directory under \ClientScript named lightbox and upload jquery.lightbox-0.5.min.js, jquery.lightbox-0.5.css and the images directory included in the zip to this new directory.
    2. Browse to the directory containing your site's skin (\data\sites\[SiteNumber]\skins\NameOfSkin and download the layout.master file.
  3. Using your favorite HTML editor (mine is Notepad++):
    1. Add the following lines to the layout.master directly after the <asp:ScriptManager control
      <link href="/ClientScript/lightbox/jquery.lightbox-0.5.css" type="text/css" rel="stylesheet" />
      <script type="text/javascript" src="/ClientScript/lightbox/jquery.lightbox-0.5.pack.js"></script>
      <script type="text/javascript">
      	$(document).ready(function(){
      		$('a.lightbox').lightBox({
      			imageLoading:	'/ClientScript/lightbox/images/lightbox-ico-loading.gif',
      			imageBtnClose:	'/ClientScript/lightbox/images/lightbox-btn-close.gif',
      			imageBtnPrev:	'/ClientScript/lightbox/images/lightbox-btn-prev.gif',
      			imageBtnNext:	'/ClientScript/lightbox/images/lightbox-btn-next.gif'
      		});
      	});
      </script>
  4. Back in your FTP client, upload the modified layout.master file.

Using LightBox

Now to use LightBox, all you need to do is add lightbox as a class on any link that you want to open in a LightBox pop-up. For Example:

<a href="images/image-1.jpg" class="lightbox" title="my caption">
	<img src="images/image-1-thumb.jpg">
</a>

You can see more examples on the LightBox website.

See It In Action

Some Friendly Words of Caution

Including additional javascript files in your site will make it run slower. The difference in speed may be negligible when adding just one script but don't get carried away.

Also, you may have noticed that I put the CSS and Images in the ClientScript\lightbox directory. I did this because I couldn't get the LightBox to work properly with those items in the \Data\Style directory like they should be. Also, I couldn't get the script to work with the CSS being loaded from the CSSHandler so I had to put a reference to the CSS file in the layout.master. This should not be done without thoroughly testing your site and making every attempt to put the CSS file where it belongs, in the CSSHandler's style.config.

Conclusion

In the end, I prefer GreyBox primarily because it is already built-in to mojoPortal and it does more than LightBox. If you find that you want to use something along with GreyBox, you can adapt this post to whatever tool you decide to use. It should help get you on your way.

Happy mojo-ing!

View User Profile for Joe Davis Joe is the Founder and Managing Director of i7MEDIA. His passion is finding creative solutions to complex problems. He is married to Devyn and has three kids; Elijah, Ruth and Hannah. He is a Christian and life-long Boy Scout. When he is not at work, he's working his small homestead farm, or volunteering with the Boy Scouts or his church.

Comments

Comments are closed on this post.