Page 1 of 2

usergallery thumbpage with 2 or more columns

Posted: Tue Jan 17, 2006 5:16 pm
by lordcoffee
Hi!

I want to use the usergallery plugin but there is only one column in Thumbpage mode. Is it possible to show 2 or more?

Or is there a way that in mediagallery mode the "Fullsize images" open in a new window (popup)?

Thanks, Lordcoffee!

Posted: Tue Jan 17, 2006 7:09 pm
by mgroeninger
When I wrote the plugin there wasn't anyway to use popups with the mediagallery. I doubt that has changed, since it would have required substantial changes to the core functions that display the mediagallery... And it wouldn't be worth it just for this plugin...

The way the plugin stands right now the thumbnail page is rudimentary, ugly, and unconfigurable... that is because I don't have the css experience/knowledge to make it prettier...

If you (or anyone) have a css template they would like to see it use, post it here, send me a message, or send me an email with it...

Or, Garvin (if you read this), what is the best way to dive into Smarty? The staticpage plugin is complicated now... Is contactform a good place to look for how smarty works with Serendipity?

Posted: Tue Jan 17, 2006 8:55 pm
by judebert
Garvin reads everything. (The new motto for s9y. :))

Smarty is actually pretty easy. I added it to my newbox plugin with very little effort.

Basically, you make a PHP array. Then you use serendipity_getTemplateFile to make sure the template in question exists. Then you call serendipity_smarty_fetch to run the Smarty template on your array. What comes back is formatted HTML.

The only caveat is that the template has to be in your theme directory or your default directory. If its not, you can't find it. So you'll need some default to fall back on if the template file can't be found.

Posted: Tue Jan 17, 2006 9:04 pm
by mgroeninger
Judebert (since you beat Garvin to it *grin*),
Smarty can actually run loops, right? Does it make sense to build it so that the template itself loops through an array of images (rather than the plugin), so that people can build multi-column templates easily? Or am I thinking of something else?

lordcoffee,
I probably wont have time to work on this today but I might get some time later this week, hopefully...

Posted: Tue Jan 17, 2006 9:43 pm
by judebert
Smarty can run loops in multiple ways. The {foreach} directive is probably your best bet.

Your plugin would loop through all the available images, doing whatever filtering it likes, to build a one-dimensional array of image URLs. (Smarty can handle multi-dimensional arrays, but we're going for the quick kill, here.) Each array entry could also contain stuff like a comment, title, flags, or whatever.

The Smarty template would loop through the array, adding a new table row (or however you want to do it) every n images. For instance, if you set your array using $serendipity['smarty']->assign('thumbnails', $myarray):

Code: Select all

  <table id="thumbnails">
    {foreach from="thumbnails" item="thumb"}
      {* print a <tr><td> for the first, <td> for second and third *}
      {cycle values="<tr><td>,<td>,<td>"} 
      <a href="{$thumb.link}><img src={$thumb.src}><span>{$thumb.comment}</span></a>
      {cycle values="</td>,</td>,</td></tr>"}
    {/foreach}
  </table>
That would print a table of thumbnails, 3 wide, using the $thumbnails[n].link, .src, and .comment from your plugin.

Phew.

You could, of course, set up the cycle values in your plugin, too. Or pass a width option, and check a variable, like so:

Code: Select all

  {foreach id="cols" from="thumbnails" item="thumb"}
    {if $smarty.foreach.cols.iteration is div by $thumbnails.width}
     <tr>
    {/if}
      <td>
...
That way your plugin could allow the user to configure the number of columns in his media gallery.

Posted: Wed Jan 18, 2006 12:23 am
by lordcoffee
O.K., here you can see what I've done with the serendipty_event_usergallery.css and a little editing the php file. My Problem is that the Pictures and the borders do not fit in one horizontal line. Do you have an Idea what can fix this Prob?

Posted: Wed Jan 18, 2006 5:11 am
by judebert
There's nothing joining together the serendipity_gallery_thumbs and the serendipity_gallery_title. The titles are divs, so they're going directly below each other. I believe the thumbs are floated divs, so they get stacked to the left.

If you place the _title inside the _thumbs, I believe it'll do what you want.

Good Luck!

Posted: Wed Jan 18, 2006 8:42 am
by lordcoffee
O.K., thanks Judebert! The only Problem now is the size of the Thumbs.
The pictures in portrait format are higher than the landscape format pictures (of course they are :wink: ). Is there a way to set kind a minimal or maximal height?

HERE

Thanks, Lordcoffee!

Posted: Wed Jan 18, 2006 8:47 am
by garvinhicking
Since Judebert already answered everything perfectly, I just wanted to acknowledge his statement of me reading everything ;-))

Best regards,
Garvin

Posted: Wed Jan 18, 2006 10:46 am
by lordcoffee
The size problem is fixed now. I just added height and width to the Thumbs.

If I now upload e.g. *.mpg files it shows "download... blablabla.mpg". Is it possible to show the "Image" for mpg files and for .mov... tiff...
like it is in the medialibrary mode.

Posted: Wed Jan 18, 2006 1:53 pm
by lordcoffee
Now I get the "package-image" if a file is no image but the problem is that I used a static path to it:
<a href="<?php echo $Fullimage; ?>" target=blank><img src="/blog/templates/default/admin/img/mime_unknown.png"></a>
How can I get this variabel? Because if anyone uses this plugin and his install directory isn't "blog" it won't work. Any Ideas?

Thanks, Lordcoffee!

Posted: Wed Jan 18, 2006 3:44 pm
by judebert
In PHP, use serendipity_getTemplateFile('admin/img/mime_unknown.png') to get the package image of the current template. It'll return the default template's image if the current template doesn't have one.

Posted: Wed Jan 18, 2006 3:55 pm
by lordcoffee
Thanks! But where can I put the line into?

Posted: Wed Jan 18, 2006 6:45 pm
by mgroeninger
lordcoffee,
it should be something like this:

Code: Select all

<a href="<?php echo $Fullimage; ?>" target=blank><img src="<?php echo serendipity_getTemplateFile('admin/img/mime_unknown.png'); ?>"></a>
Would you mind sharing your changes with me? I will probably still develop a smarty version of the plugin, but your css would save me a lot of work trying to make it look pretty...

Posted: Wed Jan 18, 2006 11:21 pm
by lordcoffee
Thanks to all!

Now the usergallery plugin works the way I wanted.
Take a look!

At last it would be nice to have a password field like the static_page_plugin to protect the "private"gallerys.

Greetings and good night,
Lordcoffee.