Gallery module - link to next page in popup?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Gallery module - link to next page in popup?

Post by argraff »

Hello there - I just got asked to do something I find odd, but regardless...

I have a site using the Gallery module, with lots of galleries and sub-galleries. I have it set to display only 9 pictures per page, with pagination.

The site's owner would like to have the a link to the next page below the comment on the last photo popup (lightbox, I believe) so that his visitors will know that there are more photos on the next page. (I don't think this is necessary, but I'm trying to be accommodating.) Is this possible? Is there a smarty tag call to make in the template?

I'm not a programmer, so while I can read through code and tinker, I'm not making much sense of the smarty manual. I did see reference to something like "$smarty.something.last" but couldn't figure out how to adapt it. (Here's the link: http://www.smarty.net/manual/en/language.function.foreach.php - search for '.last')

Any help would be greatly appreciated, as always.
Registered Linux User #457788
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Gallery module - link to next page in popup?

Post by Jos »

I think you hit the right smarty spot there, well done  8)

Compare the foreach statement in the module template with the smarty .last example. You'll notice there's a name added, lets say name=foo

Then add some smarty code to the title attribute, for that is what becomes the lightbox caption.

So change this:

Code: Select all

<a href="{$image->file}" title="{$image->title}" rel="lightbox[gallery]">
<img src="{$image->thumb}" alt="{$image->title}" /></a>
to this:

Code: Select all

<a href="{$image->file}" title="{$image->title}{if $smarty.foreach.foo.last} {$nextpage|escape:'html'}{/if}" 
rel="lightbox[gallery]">
<img src="{$image->thumb}" alt="{$image->title}" /></a>
The escape modifier is nescesary because lightbox needs it that way.

Note that it won't work if the last item represents a subgallery
Last edited by Jos on Tue Feb 16, 2010 11:40 pm, edited 1 time in total.
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Re: Gallery module - link to next page in popup?

Post by argraff »

So sorry! I got caught up in other projects and didn't see your reply.

Re: smarty manual - Thanks! I know just enough to really muck my code up...

I will try that out tomorrow - thank you. The template he liked best turned out to be a modified version of the Fancybox one though. How much does that change things? Below is my altered code:

Code: Select all

<!-- Fancybox  -  version 1.2.6   -  http://www.fancybox.net/ -->

<div class="gallery">
{if !empty($module_message)}<h4>{$module_message|escape}</h4>{/if}
{if !empty($gallerytitle)}<h3>{$gallerytitle}</h3>{/if}
{if !empty($gallerycomment)}<p><em>{$gallerycomment}</em></p>{/if}

{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<span class="pagelinks">{$pagelinks}</span>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}

<ul class="img-list">
{foreach from=$images item=image}
	<li class="img">
	{if $image->isdir}
		<a href="{$image->file}" title="{$image->title}"><img src="{$image->thumb}" alt="{$image->title}" /></a><br />
		{$image->title}
	{else}
   <a class="group" href="{$image->file}" title="{$image->title} {if !empty($image->comment)}- {$image->comment}{/if}" rel="gallery"><img src="{$image->thumb}" alt="{$image->title}" /></a>
	{/if}
	</li>
{/foreach}
</ul>
<div class="galleryclear"> </div>
</div>
Registered Linux User #457788
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Re: Gallery module - link to next page in popup?

Post by argraff »

Still no luck for me - I'm confused as to how lightbox and fancybox are different, and I'm not sure what name=foo is/does. Could I trouble you for some clarification? Many thanks!
Registered Linux User #457788
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Gallery module - link to next page in popup?

Post by Jos »

name=foo in the foreach tag is nescesary to be able to use $smarty.foreach.foo.last (which represents TRUE for the last item in the foreach loop)

Lightbox and Fancybox are different indeed. You'll need to go to the fancybox documentation to see how you can add a caption with html. Recently the Fancybox system got updated, so I guess this should be possible now. But I am not able to digg in to it more at the moment.

You can look for "titlePosition" and "titleFormat" in http://fancybox.net/api and http://fancybox.net/blog (tip 7)
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Re: Gallery module - link to next page in popup?

Post by argraff »

Thanks so much for your help Jos - I really appreciate the time you've put into this. Will play around with this and let you know how it goes!
Registered Linux User #457788
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Re: Gallery module - link to next page in popup?

Post by argraff »

Ok, got part of it figured out. Attached is a screenshot of the result after the following code is applied:

Code: Select all

<!-- Fancybox  -  version 1.2.6   -  http://www.fancybox.net/ -->

<div class="gallery">
{if !empty($module_message)}<h4>{$module_message|escape}</h4>{/if}
{if !empty($gallerytitle)}<h3>{$gallerytitle}</h3>{/if}
{if !empty($gallerycomment)}<p><em>{$gallerycomment}</em></p>{/if}

{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<span class="pagelinks">{$pagelinks}</span>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}

<ul class="img-list">
{foreach from=$images item=image name=foo}
	<li class="img">
	{if $image->isdir}
		<a href="{$image->file}" title="{$image->title}"><img src="{$image->thumb}" alt="{$image->title}" /></a><br />
		{$image->title}
	{else}
   <a class="group" href="{$image->file}" title="{$image->title} {if !empty($image->comment)}- {$image->comment}{/if} {if $smarty.foreach.foo.last} {$nextpage|escape:'html'}{/if}" rel="gallery"><img src="{$image->thumb}" alt="{$image->title}" /></a>
	{/if}
	</li>
{/foreach}
</ul>
<div class="galleryclear"> </div>
<p>{cms_selflink page='contact-us' text='Contact Us'}</p>
</div>
How do I make it a working link? I have no idea where that code really lies...Many, many thanks! (Note: I've had to take this code out until I try it again so my client doesn't see the html code stuff.)
Attachments
screenshot.jpg
Last edited by argraff on Wed Mar 17, 2010 9:12 pm, edited 1 time in total.
Registered Linux User #457788
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Gallery module - link to next page in popup?

Post by Jos »

It should work with the code you have now. To try it, I must say I only copied the line

Code: Select all

<a class="group" href="{$image->file}" 
title="{$image->title} {if !empty($image->comment)}- {$image->comment}{/if} {if $smarty.foreach.foo.last} {$nextpage|escape:'htmlall'}{/if}" 
rel="gallery">
<img src="{$image->thumb}" alt="{$image->title}" />
</a>
into the original Fancybox template, and added name=foo to the foreach statement.

I sent you a PM with a link to see it work  8)
User avatar
argraff
Forum Members
Forum Members
Posts: 52
Joined: Wed Nov 28, 2007 12:10 am

Re: Gallery module - link to next page in popup?

Post by argraff »

Totally weird, I can see it working fine on your site (LOVE Friesians, btw - have two draft mares myself), but I get the same result with the new code. I've compared the source code on both pages - they're exactly the same. I reset Fancy to its default template, added the code, same result. Every way I do it I get

Code: Select all

<a href="http://blahblahblah">next</a>
on the last image. (Actually with Fancybox it shows up on every image.)

Is there another setting somewhere that I need to change?

I left the code in the page this time so that you can see it live.
http://northoftheridge.com/gallery/insects/Dragonflies/1-12-56

Many thanks for the continued help! I really appreciate it, Jos.
Registered Linux User #457788
Post Reply

Return to “Modules/Add-Ons”