Calling Gallery from 2 different links; count off by 1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling Gallery from 2 different links; count off by 1

mdesign
I have a list of links in my sidebar similar to this:

<ul>
 <li><a href="/images/pic1.jpg" title="Caption 1" rel="shadowbox[Portfolio]">Pic Title 1</li>
<div style="display:none;">
 <li><a href="/images/pic2.jpg" title="Caption 2" rel="shadowbox[Portfolio]">Pic Title 2</li>
 <li><a href="/images/pic3.jpg" title="Caption 3" rel="shadowbox[Portfolio]">Pic Title 3</li>
 <li><a href="/images/pic4.jpg" title="Caption 4" rel="shadowbox[Portfolio]">Pic Title 4</li>
 <li><a href="/images/pic5.jpg" title="Caption 5" rel="shadowbox[Portfolio]">Pic Title 5</li>
</div>
</ul>

That shows one link (the others are hidden by the div) to get the user to look at the 5 picture gallery. I have another link on the other side of the page that also  links to the same gallery. It currently looks like:

<a class="viewGallery" href="/images/pic1.jpg" title="Caption 1" rel="shadowbox[Portfolio]">View The Gallery</a>

It, like the first link in the UL, links to the first image in the Gallery. My problem is that all those images are seen as part of the gallery, so the gallery thinks there are six images instead of five...it's counting the first image twice.

Am I missing a simple way to call/launch the Portfolio gallery from the extra "viewGallery" link where it won't be counted as part of the gallery? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Calling Gallery from 2 different links; count off by 1

Wizzud
Give the first anchor in your list an id (eg. id='firstInGallery')

In your 'viewGallery' link do something along the lines of...

< a class="viewGallery" href="javascript:void(0)" onclick="Shadowbox.open(document.getElementById('firstInGallery'))" title="Caption 1">View The Gallery< /a>
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Calling Gallery from 2 different links; count off by 1

mdesign
That worked like a charm, thanks. I'm using jQuery, so I kept the javascript you suggested out of the markup. Here's what I ended up with.

At the top, in the script tag:
$(document).ready( function(){
 $('a.viewGallery').click(function() {  
   var gal = document.getElementById('galleryFirst');
   Shadowbox.open(gal);return false;
 });
});

And the link:
<a class="viewGallery" href="/images/pic1.jpg" title="Caption 1">View The Gallery</a>

This way, that link stays clean and still goes to the image if the javascript isn't working.

Thanks for your quick reply!