Easily attach galleries to Newsarticles or Webpages

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Easily attach galleries to Newsarticles or Webpages

Post 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
Last edited by Rolf on Fri Jan 29, 2010 1:39 pm, edited 1 time in total.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
simon.romin
Forum Members
Forum Members
Posts: 65
Joined: Tue Jul 13, 2010 9:31 am

Re: Easily attach galleries to Newsarticles or Webpages

Post 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
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Easily attach galleries to Newsarticles or Webpages

Post by Jos »

Simon, do you mean the Gallery picker with TinyMCE?
http://wiki.cmsmadesimple.org/index.php ... th_TinyMCE
simon.romin
Forum Members
Forum Members
Posts: 65
Joined: Tue Jul 13, 2010 9:31 am

Re: Easily attach galleries to Newsarticles or Webpages

Post 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
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Easily attach galleries to Newsarticles or Webpages

Post by Jos »

TinyMCE has an image-upload option built in... you just need the right settings in the TinyMCE admin page
Post Reply

Return to “Tips and Tricks”