The Art of Joomla is a free magazine about Joomla!(TM) 1.5 for users, web masters, designers and developers alike.

Artisan: a skilled worker who practices some trade or handicraft.

The Artisan's Directory is a free community directory for amateurs or professionals that can somehow help you get more out of your Joomla! website.

Sponsors

Banner
Banner
Google Groups
Joomla! User Group Brisbane
Visit this group
Home Magazine Perfect Popups
Issue 2

the Art of Joomla - Web Master Moments

Perfect Popups

Written by Andrew Eddie
Popup images are a very popular part of web-sites today. You see them used particularly in galleries but more and more within articles in general. Joomla 1.5 gives you the ability to add popup images very easily.

The first thing to do is place the following line of code in your template index.php file:

This should be placed near the top before the html parts of your template start. That's all you need from the programming point of view.

To activate modal popups, ensure this line is placed near the top of your template index.php file, before the DOCTYPE tag:

<?php JHTML::_( 'behavior.modal' ); ?>

Then just put a link in your content like this:

<a class="modal" href="/images/stories/big_picture.jpg">
<img src="/images/stories/thumb_picture.jpg" border="0" alt="A picture" /></a>

You only have to remember three things.

  1. Put your thumb size image in a link.
  2. Point the link href to your full sized image.
  3. Include a class of modal in the link tag.

The screenshot to the right uses this technique.

Next time I'll show you how to use a different popup called Slimbox. It's a bit fancier, will support a gallery and is actually lighter on resources.

How it Works

The modal behaviour is a javascript routine that searches through all the output of the page and searches for any link that has the modal class. It then attaches a behaviour to the link that creates the popup window to the image referred to in the link. This technique is called applying "unobtrusive javascript". The huge advantage of this is it degrades well if javascript is not present. By this we mean, if you browser does not support javascript (like in some phones, WAP devices, etc) you still have valid HTML markup that a user can use. The user will still see the thumbnail picture and this will link to the larger image. Whether it's too big for their screen is another matter – but at least they can still see the information.

(15 Votes)

2 Comments

  1. Rick makes this comment

    Can you explain this in newbie terms. I am using Joomla 1.5 & TinyMCE editor

    Thu 03 Apr 2008 13:57:17 CDT

  2. Rick makes this comment

    I got this to work. How do you get the original size image (big picture)to pop up?

    Fri 04 Apr 2008 13:12:45 CDT

Add a Comment