This page is about having more than one SmoothGallery on a single page. First, we’ll have a look at the implementation. Second, we think about a solution with WordPress and the SmoothGallery plugin.
How to do this
Having more than one gallery on a single page boils down to this:
- add as many galleries as you want to your page, each having a different
id, e.g. set the first one tomyGallery, the second tomyGallery2, etc. - insert as many CSS stylesheets as you’ve inserted galleries like so:
<link rel="stylesheet" href="css/jd.gallery.css" [...]/> <link rel="stylesheet" href="css/jd.gallery2.css" [...]/>
Replace the id
myGalleryfrom the default stylesheet with your unique ids from step one. - what you did in step two with the stylesheets needs to be repeated with JavaScript variables that hold instances of your galleries. To do this add lines like the following:
function startGallery() { var myGallery = new gallery($('myGallery'), { timed: false }); var myGallery2 = new gallery($('myGallery2'), { timed: false }); } window.addEvent('domready',startGallery);
Once you’ve done all that you’ll have more than one gallery running on a single page.
Implementation
If we wanted to implement this generically in a plugin for WordPress we would have to get the ids of every gallery that should be displayed on the current page. With this information we could generate the JavaScript and CSS.
This seems to work great if the markup for the galleries is inside a single post or page because we can simply implement a filter that collects every id from the content. This filter thing may even work for the frontpage of WordPress. Unfortunately this isn’t possible anymore if there’s a gallery in the sidebar: there must be a unique id for this.
Since this implementation might be time consuming I stopped working on it. If you’d like to help me working on this I’d really like to hear from you.
9 comments ↓
thumbs up.
Adham
This is a pretty old article but I just came upon it, so hopefully I’ll get a response
I tried this method, but it doesn’t seem to want to work with IE7. One or two galleries seem to display properly but the rest just keep “loading”, and no pictures show up. The thumbnails do, and you can click on the images to bring up a larger size, but the images do not display in the slideshow.
Any idea why? It works perfectly in Firefox. There are 6 galleries on one page.
Thanks! This helped a lot but hopefully I can get it working for both browsers. For now I just stuck a “get firefox” button on there, lol.
I’m sorry but I’ve never tested this with more than two galleries on a single page and at the time of this writing it worked with Safari 3, Firefox 3, Opera 9.5 and IE 6.
Have you considered putting the galleries inside iFrames instead?
I’ve found other old posts that fixed other issues but this seems to be something new with Mootools 1.2.1.
Any ideas would be great.
adding
margin: 0 auto;to the CSS selector#myGallery2should solve your problem.I am implementing a second slideshow on a oscommerce site. However I am unable to add the second variable in the same javascript instance, which is in the header. So my second instance is further down. I tried just changing the variable in the second one but it is not working, is there something I am missing?
Thanks for the plug-in and your support.
Leave a Comment