Page 1 of 2

[REOPENED] dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 3:56 pm
by ARVANDERKAMP
He guys,

I'm looking for a solution for the following issue:
I want to show specific gallery directories on different 'news' pages (using the news module).

I know that you can show different gallery directories on different pages, using {if $page_alias eq ''}.. BUT it doenst work on pages from the news gallery, because these are not defined pages from the standard user menu.

Is there another tag to make this work? Like $page_url or something like this?

Thanks in advance!

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 4:42 pm
by Wishbone
You can add an extra field definition in the news module, where you can place a Gallery directory name. In the detail template, if this field is filled out, it can show the gallery at the end (or where ever)

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 4:47 pm
by ARVANDERKAMP
Thanks Wishbone!

I searched some more and read this topic: http://forum.cmsmadesimple.org/viewtopic.php?t=40553
Probably the same thing you mentioned.. And it works so far! The gallery shows up fine!

Unless one thing, i don't want it to pop up in the content area, but in a HTML block (sidebar).
Got an idea how to make this work?

Thanks


EDIT. I already tried to move the code from the article template (news module) to a HTML block, but it doesn't work!
This is the code i mentioned:

Code: Select all

{if isset($entry->map_openbaar_album)}
      {Gallery dir=$entry->map_openbaar_album}
{/if}

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 5:05 pm
by Wishbone
I'm assuming that your sidebar is before your {content} in your page template.

Create the same extra field definition as I mentioned, and in the link you provided.

In your detail template,at the end, create a variable called $gallery_dir containing the gallery specified. {assign var='gallery_dir' value=$entry->gallery_dir} assuming that 'gallery_dir' is your extra field added.

In your page template, before your sidebar, use {content assign='content'). This will evaluate your content and store it in a variable called $content. If your content was a news article, you will have $gallery_dir defined.

In your page template, where your gallery will be, use {if $gallery_dir}{Gallery dir=$gallery_dir}{/if}

Where you used to have {content}, replace it with {$content}



If your sidebar is after your {content} in your page template, then leave {content} where it is. No need for the gimmick to evaluate the news before it's displayed.

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 7:50 pm
by ARVANDERKAMP
Because the sidebar is positioned at the right of the content, it is stated after the {content} tag in the page template.

Like this:

Code: Select all

<div class="content">
     {content}
</div>

<div class="sidebar-right">
     {global_content name='sidebar-right-projecten'}
</div>
And my article template looks like this:

Code: Select all

{* set a canonical variable that can be used in the head section if process_whole_template is false in the config.php *}
{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}

<h3 id="NewsPostDetailTitle">{$entry->title|cms_escape:htmlall}</h3>

{if $entry->postdate}
	<div id="NewsPostDetailDate">
		{$entry->postdate|cms_date_format}
	</div>
{/if}

<hr id="NewsPostDetailHorizRule" />

<div id="NewsPostDetailContent">
	{eval var=$entry->content}
</div>


{if isset($entry->map_openbaar_album)}
      {Gallery dir=$entry->map_openbaar_album}
{/if}


{if $entry->extra}
	<div id="NewsPostDetailExtra">
		{$extra_label} {$entry->extra}
	</div>
{/if}


{if $return_url != ""}
<div id="NewsPostDetailReturnLink">{$return_url}{if $category_name != ''} - {$category_link}{/if}</div>
{/if}


<!--
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsDetailField">
        {if $field->type == 'file'}
	  {* this template assumes that every file uploaded is an image of some sort, because News doesn't distinguish *}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}
-->
So now, i want to move the {if isset($entry->map_openbaar_album)} tag to a HTML block called 'sidebar-right'.
As stated above it shows up below my content, but i want it to show up in the right sidebar.

Could you give it one more try, because i cant figure out...

EDIT. This is the page where it's all about: http://houvastbouw.websitedelivery.nl/n ... edemsvaart

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 10:05 pm
by Wishbone
OK. Move your {if isset($entry->map_openbaar_album)}{Gallery dir=$entry->map_openbaar_album}{/if} from your gallery detail template into your global content block 'sidebar-right-projecten'

Since $entry is defined above the sidebar in the HTML, it should still exist when it gets to the sidebar.

If $entry was redefined, or doesn't exist at the time the sidebar is being created, add {assign var='map_openbaar_album' value=$entry->map_openbaar_album} at the end of your Gallery detail template and check if $map_openbaar_album is set in the sidebar content block.

Re: dynamic gallery combined with the news module

Posted: Mon Feb 14, 2011 10:28 pm
by ARVANDERKAMP
When i move {if isset($entry->map_openbaar_album)}{Gallery dir=$entry->map_openbaar_album}{/if} to my global content block 'sidebar-right-projecten', i get the following error on the page:

Parse error: syntax error, unexpected '-', expecting ',' or ')' in /home/p11246/domains/websitedelivery.nl/public_html/houvastbouw/tmp/templates_c/%%13^131^131CA9A9%%globalcontent%3Asidebar-right-projecten.php on line 5

I also added {assign var='map_openbaar_album' value=$entry->map_openbaar_album} to the bottom of the gallery detail template. But no luck so far, still the error. :(

Re: dynamic gallery combined with the news module

Posted: Tue Feb 15, 2011 10:14 pm
by Wishbone
I was able to log in and help him to get it to work.

http://houvastbouw.websitedelivery.nl/n ... edemsvaart

To summarize, he wanted to show specific galleries in his right sidebar in certain News articles. He defined a extra field definition 'map_openbaar_album' that would contain the Gallery directory. What we did was add to the News detail template:

Code: Select all

{assign var='map_openbaar_album' value=$entry->map_openbaar_album}
..which copies the value of the Gallery directory to a variable. For some reason, $entry in the News template doesn't seem to be usable later on in the site template, but other variables defined do. Later on in the template, where his sidebar is defined, we added:

Code: Select all

{if $map_openbaar_album}
{Gallery dir=$map_openbaar_album}
{/if}
..which checks to see if the variable is defined, and if so, display the gallery that the News editor specified.

Luckily his right sidebar was defined after {content}, or we would have had to do some other Smarty magic involving redirecting {content} output to a variable, display the gallery, then use the content variable instead of {$content}.

Re: dynamic gallery combined with the news module

Posted: Tue Feb 15, 2011 10:36 pm
by ARVANDERKAMP
Thanks for explaining Wayne!

A little addition, step by step, containing the whole process:
1) Install the gallery plugin for using the different gallery directories
2) Add a field definition to your News module, call it whatever you like, i used 'map_onderbaar_album'
3) Add this following line to the Article template from the News module: {assign var='map_openbaar_album' value=$entry->map_openbaar_album}
4) Create a HTML block (which is your sidebar to the right of the content) and add the following code: {if $map_openbaar_album}{Gallery dir=$map_openbaar_album}{/if}
5) Finally, create a news article and add the gallery directory tag to the new field at the bottom of the page.

That should do the trick!

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 11:55 am
by pedes
i have some same issue ...

I use also Gallery in my news detail, but i only want to show 1 thumb at the time, so i have some gallery paging buttons.
(see attached file)
everythng works fine , until i select the second or another gallery-page to see anothe thumb then the first.
then i get back to the news summary instead of seeing the second or another gallery thumb

is there a way to get the gallery in news detail work with the gallery-paging on?

thanks for any hints

kind regards
Peter

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 12:11 pm
by ARVANDERKAMP
Could you send a link of the certain page?
Would be a lot easier for looking into it..

Alexander
pedes wrote:i have some same issue ...

I use also Gallery in my news detail, but i only want to show 1 thumb at the time, so i have some gallery paging buttons.
(see attached file)
everythng works fine , until i select the second or another gallery-page to see anothe thumb then the first.
then i get back to the news summary instead of seeing the second or another gallery thumb

is there a way to get the gallery in news detail work with the gallery-paging on?

thanks for any hints

kind regards
Peter

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 12:55 pm
by pedes
this is the link (testserver)
http://www.redstarcom.net/cms193/index. ... chitectuur

you will see the summary of news and then click on 1 of the 2 links (2010...) to see the detail (with the gallery in it)
for now i let the news compleet on the right side, but it is the meaning the gallery will be exposed on the left and the news info on the right (with the use of div's) , but first i want to get it work in the original way.

thank you very much for any help.

Kind regards
Peter

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 4:09 pm
by ARVANDERKAMP
Hmmpff, the link is dead...
pedes wrote:this is the link (testserver)
http://www.redstarcom.net/cms193/index. ... chitectuur

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 4:55 pm
by pedes
ARVANDERKAMP wrote:Hmmpff, the link is dead...
pedes wrote:this is the link (testserver)
http://www.redstarcom.net/cms193/index. ... chitectuur
I'm sorry ... site was on maintenace-on ... now it should work

Thnk you for checking it out

Peter

Re: [SOLVED] dynamic gallery combined with the news module

Posted: Wed Mar 23, 2011 8:34 pm
by ARVANDERKAMP
The gallery on the 'stabiliteit' page does seem to work correctly. The other gallery, from the 'architectuur' page seems to link to the previous page.

Looks like you got an error in your Gallery template which results in linking back to the previous page. What happens if you try another Gallery template, like Lightbox?

Are you using the same template for the 'architectuur' and 'stabiliteit' page?