Page 1 of 1

Easily attach galleries to Newsarticles or Webpages

Posted: Mon Jan 11, 2010 7:24 pm
by Rolf
With a few small changes you can easily attach photogalleries(Gallery module) to newsarticles and webpages.
It provides a field under the text editor where you can copy the foldername of the gallery you want to show.
Once filled in the foldername, the gallery will appear on the bottom of the page. Easy as that ;)

Foldername: uploads/images/Gallery/folder/folder

News Module

1.Create in the News module the Field Definitions you need:

Content >> News >> Field Definitions
->   folder_public_gallery
->   folder_secure_gallery
and check 'Public'!

2.Modifications to the article template:

Code: Select all


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

{* --- Addition public gallery --- *}
{if isset($entry->folder_public_gallery)}
       {Gallery dir=$entry->folder_public_gallery}
{/if}
{* --- End --- *}

{* --- Addition secure gallery --- *}
{if isset($entry->folder_secure_gallery)}
       <p><b>The gallery is only visible for authorized visitors of this website!</b></p>
       {if $ccuser->loggedin()}
             {Gallery dir=$entry->folder_secure_gallery}
       {/if}
{/if}
{* --- End --- *}

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

3.Comment out ( ) this part of the template, otherwise the foldername will appear under the article:

Code: Select all


<!--
{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}: {eval var=$field->value} 
        {/if}
     </div>
  {/foreach}
{/if}
-->



Webpage

Addition to the HTML-template:

Code: Select all


{content}<br />

{* --- Addition public gallery --- *}
{content block='Folder public gallery' oneline='true' wysiwyg='false' assign='galleryfolder'}

{if $galleryfolder}
       {Gallery dir=$galleryfolder}
{/if}
{* --- End --- *}


{* --- Addition secure gallery --- *}
{content block='Folder secure gallery' oneline='true' wysiwyg='false' assign='galleryfolder_secure'}

{if $galleryfolder_secure}
       <p><b>The gallery is only visible for authorized visitors of this website!</b></p>
       {if $ccuser->loggedin()}
       {Gallery dir=$galleryfolder_secure}
       {/if}
{/if}
{* --- End --- *}

Nederlandse versie: http://forum.cmsmadesimple.org/index.ph ... 919.0.html


If you want to create a secure gallery, you also need Frontend Users and Custom Content of course!
http://calguy1000.com/uploads/1/Hiding_ ... e-pdf.html

Re: Easily attach galleries to Newsarticles or Webpages

Posted: Sun Oct 03, 2010 4:49 pm
by simon.romin
Hi!

Thanks for posting this information - very useful.

One quick question...

At the moment I have to manually create a directory for the page and manually upload images to that directory.

Would it be possible to add an image uploader in the Content Editor, rather than manually typing in the folder gallery?

Thanks again,

Simon

Re: Easily attach galleries to Newsarticles or Webpages

Posted: Sun Oct 03, 2010 5:04 pm
by Jos
Simon, do you mean the Gallery picker with TinyMCE?
http://wiki.cmsmadesimple.org/index.php ... th_TinyMCE

Re: Easily attach galleries to Newsarticles or Webpages

Posted: Sun Oct 03, 2010 6:42 pm
by simon.romin
Thanks for the reply Jos, but I was looking more for an image uploader interface. I want to be able to upload the images directly from my computer to the content page without having to manually create directories.

The method you suggested works, but I still need to create the directories in the Gallery folder (similar to Rolf's solution)

You aren't aware of an image uploader interface I can use?

Thanks

Simon

Re: Easily attach galleries to Newsarticles or Webpages

Posted: Sun Oct 03, 2010 6:47 pm
by Jos
TinyMCE has an image-upload option built in... you just need the right settings in the TinyMCE admin page