The Gallery plugin

Creating and modifying plugins.
Post Reply
hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

The Gallery plugin

Post by hyejohn » Fri Aug 07, 2009 7:53 pm

I'd like to make a mod to the gallery plug-in

I made some changes, via tpl in my template, to make it use lightbox, but this could just be one of the options through the admin screen. This I know how to do.

The other change I'd like to make is to have an optional text description file in each directory and sub-directory that the gallery would use to put pre-text on the screen. Unless I could do this through the tpl as well...? This I don't know how to do.

Suggestions?
~John
That Photographer guy in Michigan

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: The Gallery plugin

Post by Don Chambers » Fri Aug 07, 2009 9:31 pm

Can't you just use media properties for the text you want to display, then modify your template to display those additional fields?

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Fri Aug 07, 2009 9:49 pm

No, That's applied per image - I want to apply a description to a directory of photos.

So when the page appears, it will appear:

********************
* Header
********************
* Pre-text
* Gallery Folder Navigation
* Pic Pic Pic Pic Pic
* Pic Pic Pic Pic Pic
********************
* Footer
********************

Where the 'Pre-text' is retrieved from a text file in the folder (Like Photo_Gallery_Desc.txt)

This way, I can describe information (Who, What, When, etc.) about the photos in the gallery as a whole instead of relying on the folder name as a description.
~John
That Photographer guy in Michigan

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: The Gallery plugin

Post by Don Chambers » Fri Aug 07, 2009 9:55 pm

How about a description for each media folder in addition to its name (assuming that is possible...)?

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sat Aug 08, 2009 2:09 am

That would work. You mean entering something from the admin panel under manage directories?


I thought about this a little more and think it might be possible to do from the tpl using a php include command... :idea:
~John
That Photographer guy in Michigan

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sat Aug 08, 2009 2:38 am

Okay, I've been looking into this more and I'm running into multiple problems.
1) The txt file gets pulled on to the page as an item in the file - I only want my jpg images to get pulled in!
2) The txt file is getting counted as an image and is showing up in the file count in the navigation.

hmmmm...Create a second set of directories that mirror the photo directories?
~John
That Photographer guy in Michigan

mgroeninger
Regular
Posts: 546
Joined: Tue Dec 21, 2004 12:57 am
Contact:

Re: The Gallery plugin

Post by mgroeninger » Sat Aug 08, 2009 4:43 pm

Hi hyejohn,

About lightbox integration: I've thought that would be a cool idea, but I would want it to detect if the lightbox plugin is installed and use it, rather than bundle the library with the gallery plugin. Unfortunately, I don't know anything about what Lightbox (Thickbox JS/Greybox) need to work. if you can post a small example of the changes you made to your tpl I can look into this.

About directory metadata:

Probably the best way to do this is with a database and to make it somewhat robust. That will take time.

A quicker way to do this would be to use a small xml file in your template directory and have some php pull out the info if it exists.

If the xml was somthing like this:

Code: Select all

<dir name="Top Directory" descrip="root directory">
  <dir name="Subdirectory1" descrip="First sub-directory"></dir>
  <dir name="Subdirectory2" descrip="Second sub-directory"></dir>
</dir>


You could parse through it pretty quick and add the description field to the folder array based on matching name/level. That would also mean you could have a single file and several different gallery plugins (if you are using it that way).

I've been looking at changes to the gallery plugin, too. The first thing I want to do is remove the exif library that is bundled with it and push that workflow into Serendipity to use the metadata that is in the database. I think that would clean up the plugin a bit. If I can do that, I have some additions to the s9y exif parsing I'd like to see (longitude and latitude, little things like that).

I am also working on a rewrite of the Amazon sidebar, though, and I promised that first.

Matt

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sun Aug 09, 2009 12:40 am

This is the plugin_usergallery.tpl change I made to use the lightbox:

Code: Select all

{if $plugin_usergallery_image_display eq 'popup'}
   <!-- popup -->
   <a href="javascript:popImage('{$image.fullimage}','{$image.name}','{$image.dimensions_width}','{$image.dimensions_height}')">
      <img class="gallery_thumb" {if $plugin_usergallery_fixed_width !=0}height={$plugin_usergallery_fixed_width}px width={$plugin_usergallery_fixed_width}px{/if} src="{$image.link}" border="0" alt="" />
   </a>
{else}
   <!-- show thumb and set link for lightbox -->
   <a href="{$image.fullimage}" rel="lightbox[thispage]" target="_blank" title="{$image.name}">
      <img class="gallery_thumb" {if $plugin_usergallery_fixed_width !=0}height={$plugin_usergallery_fixed_width}px width={$plugin_usergallery_fixed_width}px{/if} style="width: 100%;" src="{$image.link}" alt="" />
   </a>
{/if}


I included the style sheet needed in my own style sheet and the js library in my template directory, so I'm working totally within my template right now. I'm trying not to mess with any thing outside of the template directory.

If you want to see it in action, you can see my work-in-progress site: http://lucassian.com/

I'm only using one instance of the usergallery plugin. I should also mention that I'm not using pagination since the way lightbox works, the "next" image past the end of the page won't come up as part of the gallery.

Please go ahead and finish the Amazon sidebar! I'm having fun trying to figure this out right now! :lol:
~John
That Photographer guy in Michigan

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sun Aug 09, 2009 1:41 am

I tried adding this code to the tpl file in my template:

Code: Select all

{if $plugin_usergallery_currentgal!==""}
CurrentGal: {$serendipityHTTPPath}uploads/d{$plugin_usergallery_currentgal}desc.htm
{include file='{$serendipityHTTPPath}uploads/d{$plugin_usergallery_currentgal}desc.htm'}
{/if}


This only works in SUB-directories of the gallery, but the first line does work and yields a path to a second directory set in the uploads path that I put desc.htm files into.

I went through the smarty site and followed the instructions to include a file (NOT include_PHP)

What I got as a result was:

Code: Select all

CurrentGal: /blog/uploads/dportfolio/Headshots/desc.htm
Warning: Smarty error: unable to read resource: "{/blog/" in Y:\www\blog\bundled-libs\Smarty\libs\Smarty.class.php on line 1092
uploads/dportfolio/Headshots/desc.htm'}


(I'm testing locally which is why you see the "Y:\www\" in there.)
~John
That Photographer guy in Michigan

mgroeninger
Regular
Posts: 546
Joined: Tue Dec 21, 2004 12:57 am
Contact:

Re: The Gallery plugin

Post by mgroeninger » Sun Aug 09, 2009 2:58 am

The gallery using lightbox looks great!

And I think that those changes would be pretty easy to build in so that we can enable them from the admin page if the other event plugin is installed.

I think the problem you are seeing with the include line is because your result is a relative path, not an absolute path.

Unfortunately, I believe I wrote the plugin so that the template file only gets a relative path, since the design is for the images to always be within the web server's root and from the client side you shouldn't know (or care) about absolute paths.

Newer versions of Smarty allow for a "$smarty.current_dir" variable that might be helpful, but I don't think that is available.

I'll see if I can find a variable that gets imported that might be useful.

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sun Aug 09, 2009 3:51 am

I got the following code to return my desc file on the page:

Code: Select all

{include file="Y:\www$serendipityHTTPPath/uploads/d$plugin_usergallery_currentgal/desc.tpl"}


It looks into the mirror directory of the gallery I'm in for the desc.tpl file. I setup the directory structure like this:

uploads
&nbsp;&nbsp;&nbsp;portfolio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;headshots
&nbsp;&nbsp;&nbsp;dportfolio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;headshots

where the "d" version contains the desc.tpl file.

The problem is the "Y:\www" portion of the code. On the Smarty website, they talk about using the absolute path or related path to $trusted_dir when using the include command.

$serendipityPath $serendipityFullPath and $trusted_dir yield a null result. I might have to solve this with a template variable but I'm still trying to figure out a standard way to do this...
Last edited by hyejohn on Sun Aug 09, 2009 4:01 am, edited 1 time in total.
~John
That Photographer guy in Michigan

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Sun Aug 09, 2009 4:00 am

mgroeninger wrote:...changes would be pretty easy to build in so that we can enable them from the admin page if the other event plugin is installed.


That should work, but I did have to change the lightbox style sheet to make it work the way I wanted. (Which I could still do as long as the template style sheet appears after the lightbox stylesheet.)

SOME of the graphics that lightbox uses were being called in the javascript and the references were to a image directory off the base directory, so I removed those references and put the graphic references into the template stylesheet. - I don't know if the lightbox plugin was coded to correct this.

By bundling the lightbox code with the template I've eliminate the need for the separate lightbox plugin.
~John
That Photographer guy in Michigan

hyejohn
Regular
Posts: 37
Joined: Mon Jun 22, 2009 4:04 pm
Location: Michigan, USA
Contact:

Re: The Gallery plugin

Post by hyejohn » Mon Aug 10, 2009 3:12 am

I couldn't wait any longer and I'll just have to live with the comment structure I worked out.

I ended up having to include my actual path in the tpl file - when I tried using a template option it choked on me and returned a string with array.---- in it.

I'll try to get my overall template cleaned up and packed up so I can let others have a crack at it.

I named it 'electric' - mostly because I was creating it for use with a lot of static pages, but the biggest feature is probably the lightbox use in the gallery tpl file (and my css files)
~John
~John
That Photographer guy in Michigan

Post Reply