[solved] Gallery:how 2 change gallery template on next level

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
map_1961
Power Poster
Power Poster
Posts: 406
Joined: Fri Apr 20, 2007 7:26 pm
Location: Ruhrstadt

[solved] Gallery:how 2 change gallery template on next level

Post by map_1961 »

Hi.

We use gallery module on home with limit "3" to show latest galleries there. We wrote a template for this purpose including pic-icon overlay
When i click on one of this album covers to open the gallery behind it the gallery is still shown with limit of three pics per page.
Is there a way to change templet on next level?
See http://www.papageienpark-bochum.de

Thanks

map_1961
Last edited by map_1961 on Wed Nov 28, 2012 1:32 pm, edited 1 time in total.
Marijus

Re: Gallery - how 2 change gallery template on next level?

Post by Marijus »

You can try this:
assign home page

Code: Select all

{assign var='home' value='1'}
and in tamplate add this

Code: Select all

{if isset($home)}
{Gallery tamplate="1"}
{else}
{Gallery tamplate="2"}
{/if}
User avatar
map_1961
Power Poster
Power Poster
Posts: 406
Joined: Fri Apr 20, 2007 7:26 pm
Location: Ruhrstadt

Re: Gallery - how 2 change gallery template on next level?

Post by map_1961 »

Thankx Marijus.

I'll check that out after Oct. 22nd when i'm back from trip.

map_1961
User avatar
map_1961
Power Poster
Power Poster
Posts: 406
Joined: Fri Apr 20, 2007 7:26 pm
Location: Ruhrstadt

Re: Gallery - how 2 change gallery template on next level?

Post by map_1961 »

Hi Marijus,

we created a sub page with page alias 'neueset-fotostrecken' and tried this - writing to the home page content area:

Code: Select all

{assign var='home' value='1'} {if isset($home)} {Gallery dir='impres/2012' template="Fancybox_HOME_ohne_Navi_ohne_Bildanzahl_icon" number="3" targetpage="neueste-fotostrecken"} 
{else} 
{Gallery dir='impres/2012' template="Fancybox_ohne_Navi" targetpage="neueste-fotostrecken"} {/if}
The query seems to work fine because if we delete the {assign var='home' value='1'} the gallery is shown without limit 3.

We have to switch the gallery call to another page because if we stay on home the page alias stays with home and the query can't work. So we added

Code: Select all

targetpage="neueste-fotostrecken"
But it seems that this call doesn't work. If we click the gallery thumb on the home page we open the gallery but stay on page alias home and with the limit of three pictures shown. So far we have NO working solution, yet.

map_1961

----

We meanwhile detected that we swith to the page alias "neueste-fotostrecken" but the swith to the other gallery template doen't work yet. We try to solve...
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Gallery - how 2 change gallery template on next level?

Post by velden »

First of all: the target page itself has some errors:

Code: Select all

<__script__>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'YOUR_APP_ID', // App ID
      channelUrl : 'http://http://www.facebook.com/Papageienpark.Bochum' // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });
Double 'http://' and probably you need to escape those '//' because Javascript interprets them as comment

Code: Select all

http:\/\/www.facebook.com/Papageienpark.Bochum'
404 error on

Code: Select all

<__script__ type="text/javascript" src="modules/Gallery/templates/jquery/jquery.mousewheel.pack.js"></__script>
Furthermore, jQuery library is not included anywhere as far as I can see.

About the conditional Gallery calls: I think it doesn't work because the Gallery module will completely 'replace' the {content} tag with his own contents. This would mean that you have to do your logic in the Gallery templates.

I once did something like you want I guess. It does NOT involve another target page alias. In your case it would show the photo's on the home page.

I created two templates within Gallery

Template 'gallerytree2':

Code: Select all

<div id="projecten"><ul>
{foreach from=$images item=image name=img}
{if $smarty.foreach.img.index == 0}{assign var="org_gallerydir" value=$gallerydir}{/if}
{Gallery dir="projecten/`$org_gallerydir`/`$image->filename`"}
{/foreach}
</ul></div>
This template will walk through the images of (sub)galleries and everytime it finds an image with index == 0 it will the Gallery module again. Because the inner Gallery call has no template parameter, it uses the default tempate for that:

Template 'gallerytree' (set as default template!):

Code: Select all

{foreach from=$images item=image name=img}
{if $smarty.foreach.img.index > 0}</li>
{/if}

<li{if $smarty.foreach.img.index > 0} class="hide"{/if}><a class="fancybox-thumbs" data-fancybox-group="thumb{$galleryid}" id="fototekst" title="{$image->comment}" href="{$image->file}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="">{if $smarty.foreach.img.index == 0}<span>{$gallerytitle}</span>{/if}</a>

{assign var='g_prevdepth' value=$image->depth}
{/foreach}
</li>
{if $gallerycomment}
<li class="hide"><a class="fancybox-thumbs" data-fancybox-group="thumb{$galleryid}" href="#inline{$galleryid}"><img src="{uploads_url}/template/images/txt.jpg" alt="" />Extra informatie</a></li>
<li><div id="inline{$galleryid}" style="width:800px;display: none;">{$gallerycomment}</div></li>
{/if}
Then, in the page content I call the Gallery with template 'gallerytree2'

Code: Select all

 {Gallery dir="projecten/klassiek" template="gallerytree2"}
You might want to use the 'number' parameter here and of course another starting directory.

Of course you should alter this code to suite you needs but I guess it could get you in the right direction.

I just saw the <div> inside the <li> in the last template, which I think is not valid html. But again, this example could point you in the right direction.
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Gallery - how 2 change gallery template on next level?

Post by manuel »

Hi map_1961,

Maybe you can do it by changing the way you limit the number of galleries being shown.

This is just off the top of my mind... (not tested)

In your gallery call, drop the number="3"
Add this in your page template (above the gallery call!)
{if $page_alias eq 'home'}
{assign var='limitgaldirs' value='1'}
{elseif $page_alias eq 'neueste-fotostrecken'}
{assign var='limitgaldirs' value='0'}
{/if}

In your gallery template, you are now able to use the "galdirs" variable to change the number of directories shown by the by adding a {if $galdirs eq '1'} inside the {foreach...

To actually limit the number of directories shown you should be able to use something like "$var@index"
(new smarty 3 feature, cfr. http://www.smarty.net/docs/en/language. ... erty.index)
You could possibly use something like this:
{if ($limitgaldirs eq '1' && $image@index lte 3) || ($limitgaldirs eq '0')}
Show me the directory thumb :)
{/if}

If the @index thing doesn't work (haven't used it myself yet), you might have to add "name=something" to the foreach (like this: {foreach from=$images item=image name=something}) and replace $image@index with $something@index
Or you could use a old school smarty 2 count :)

Let me know if this pushes you in the right direction or if you need me to elaborate on some of it!

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
map_1961
Power Poster
Power Poster
Posts: 406
Joined: Fri Apr 20, 2007 7:26 pm
Location: Ruhrstadt

Re: Gallery - how 2 change gallery template on next level?

Post by map_1961 »

Hi guys.

Thank u so much for this imput. As we are mostly content & design people we have a lack in smarty and coding knowledge and can not handle this hints...
We stoppt working on this issue. Three pictures on each page - we have to live with this. Maybe the module itselfe will offer a solution n for this purpose sometimes.

Thanks once again.

map_1961
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Gallery - how 2 change gallery template on next level?

Post by manuel »

Dear Martin,

The solution was:
1. remove the number=3 from the gallery tag
2. add the code below in front of the gallery tag

Code: Select all

{assign var='limitgaldirs' value='1'}
3. edit the gallery template:
Change

Code: Select all

{foreach from=$images item=image}
To

Code: Select all

{foreach from=$images item=image}
{if ($limitgaldirs eq '1' && $image@index lte 2) || ($limitgaldirs eq null)}
Change

Code: Select all

{/foreach}
To

Code: Select all

{/if}
{/foreach}
Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Post Reply

Return to “Modules/Add-Ons”