Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2008-04-10 22:27:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: smd_gallery: super-flexible gallery generator

Hehe, you’re not alone: the way this one’s going is astounding me!

It always bugged me that I managed to get smd_slimbox to be able to do multiple galleries from one call but smd_gallery — the supposed upgrade — couldn’t do it cleanly. I’d hoped that breaking stuff out into forms would allow some cunning uses of <txp:if_different> but it had two unforeseen (at least by me) drawbacks:

  1. it only seemed to function properly when images were sorted by category
  2. if using the thumblimit facility, you’d only get thumbnails for the 1st gallery. All subsequent galleries would get titles but no thumbs. Clearly sub-optimal

So I knew I needed a way of optionally “resetting” the thumblimit counter when a category changed and tried several (failed) attempts at conditional tags; all of which involved horrible globals and messy code. Then I twigged that I could merely make the {replacements} conditional and it all fell into place. The unexpected bonus was that with one extra attribute I could make just about every piece of image data conditional, instead of simply categories. As Hannibal would say: “I love it when a plan comes together”

I hope (abuse of) the new features take people to hitherto uncharted gallery lands.

And masa, I never thought of using overrides like that; great tip, thanks :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#50 2008-05-08 12:57:41

fangonk
Member
Registered: 2007-07-12
Posts: 44

Re: smd_gallery: super-flexible gallery generator

Hey Bloke,

Im putting together a website for a client and they are twisting my arm in to giving them a very basic (non-slimbox) image gallery – a whole bunch of little thumbnails that when clicked open up a larger version.

Here is how I’ve got it set up in the page template:

<div id =“archivet1”>
<txp:smd_gallery category=“welcomes” thumb=“1” form=“gallery” />
</div>

And in the gallery form:

<a href=”{imagepath}{id}.jpg”>
<img class=“thaclass” src=”{url}” alt=”{alt}” />
</a>

I know this seems like an overly complex way to set this up, but after a lot of trial and error, I couldn’t seem to set it up in a more simple way. When I use the {url} tag, the plugin always outputs a link to the thumbnail and if I removed thumb=“1” in the template, the plugin always outputs the full size image on the thumbnail page.

This more complex set up would be OK with me, but now I want to output the fullsize image using a form and keep it in the context of the rest of the site. Any suggestions? Is this question really unclear? Probably.

Last edited by fangonk (2008-05-08 13:00:19)

Offline

#51 2008-05-08 18:35:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: smd_gallery: super-flexible gallery generator

fangonk wrote:

Is this question really unclear?

Currently, for my puny brain, I’m afraid the answer is yes :-s Is it related to your other post?

a whole bunch of little thumbnails that when clicked open up a larger version.

By “open up”, what do you mean? Popup the full size image in a new window? Or populate a div with the fullsize version of the clicked thumb (like rss_thumbpop)? Or something else? The answer to that will dictate how the gallery form and tag are used.

When I use the {url} tag, the plugin always outputs a link to the thumbnail and if I removed thumb=“1” in the template, the plugin always outputs the full size image on the thumbnail page.

You did remember that the thumb option has changed in the latest release to work like smd_slimbox. i.e. using thumb="1" (equivalent to thumb="1:1") will tell the plugin to use the ‘t’ image for both fullsize and thumbnail. Omit it (or use thumb="0:1") for conventional operation — the 1st number specifies whether to display a thumbnail for the fullsize image, and the 2nd number is whether to display thumbnails in the thumb gallery. 0 = no; 1= yes.

If you can give a little more detail about how you want the images displayed/laid out (and/or send me a link to the work in progress site if you like) I can take a look and see if we can work out a way of doing what you want. If you’re handy with Photoshop or Paint, sketch what you want the site to behave like and we’ll go from there ;-)

EDIT: btw, look at the {thumburl} replacement tag instead of the {url} tag to show the thumb’s URL!

Last edited by Bloke (2008-05-08 18:38:10)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#52 2008-05-09 10:38:53

fangonk
Member
Registered: 2007-07-12
Posts: 44

Re: smd_gallery: super-flexible gallery generator

Sorry to bother you man, it was just a middle-of-the-night-nothing-is-working freak out. I couldn’t figure out how to get individual articles to fire using a form. Which, as I now realize is way more of a textpattern problem. Either way, I’ve got everything working now and I might just make my deadline. Thanks for taking the time to answer me, I’ll try not to leave any more annoying too-much-coffee questions. I really appreciate your patience.

Offline

#53 2008-05-09 11:03:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: smd_gallery: super-flexible gallery generator

fangonk wrote:

I’ll try not to leave any more annoying too-much-coffee questions. I really appreciate your patience.

Hey no probs. Glad you got it working. And there’s no need to apologise for posting; I learn stuff about how to use TXP (and often my own plugins!) from people posting stuff just like you did. It’s all good.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#54 2008-05-11 20:57:10

rloaderro
Archived Plugin Author
From: Costa Rica
Registered: 2006-01-05
Posts: 190
Website

Re: smd_gallery: super-flexible gallery generator

Slightly OT: just a message to let anyone who’s interested know that Slideshow 2 has officially been released!

The existing slideshow plugin – aro_slideshow – will be discontinued because the script should work perfectly with smd_gallery. If anyone gets a chance to try it out, let me know how it works. There is also a demo site up showing off some of the new features.


Travel Atlas * Org | Start Somewhere

Offline

#55 2008-05-11 21:03:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: smd_gallery: super-flexible gallery generator

rloaderro wrote:

Slideshow 2 has officially been released!

Way cool, thanks for the notification. When I get a chance I’ll give it a whirl. If there’s anything you (or anyone) can think of to make it work better/more efficiently with smd_gallery please holler. smd_gallery doesn’t have the “all-in-one” ease of use of aro_slideshow so it’ll be interesting to see how this develops.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#56 2008-05-21 17:32:03

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_gallery: super-flexible gallery generator

Bloke>
So here’s a challenge for you nyuk, nyuk, nyuk….

I have a banner that has three parts ( square image [thumb] | wide image [image] | square image [thumb] )

Requirements
  1. I want to turn it into three slideshows that operate at different speeds
  2. each slideshow dips from the same massive pool of images
  3. each slideshow must start with a different image

That’s it! I figure that if your plugin can’t help achieve this it can’t be done.

So essentially there’d be three calls to the slideshow script at different speeds drawing randomly from a common pool, but starting with a unique image…

Go go gadget brain.

Offline

#57 2008-05-21 17:40:08

jelle
Member
Registered: 2006-06-07
Posts: 165

Re: smd_gallery: super-flexible gallery generator

Hy mrdale,

I think that if you combine smd_gallery with some jQuery magic it’ll work.
Check out the Animated Innerfade plugin for jQuery:
http://www.openstudio.fr/Animated-InnerFade-with-JQuery.html?lang=en

Last edited by jelle (2008-05-21 17:40:37)

Offline

#58 2008-05-21 18:07:15

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,712
Website

Re: smd_gallery: super-flexible gallery generator

If each start image just needs to be different but doesn’t have to be random you can hard code the first image of each sequence and use smd_gallery to generate the remaining html list of images to be referenced. Then use a script like jelle suggests.

second idea: thinking aloud here, I suppose you could call smd_gallery twice for each series of images, once for the first image and once for the remaining images. If you can restrict the random selection using offset/limit then you could make the start item of the first slideshow select a random image from images 1-3, the start item of the second a random image from images 4-6, the third start item a random image from images 6-9… lots of queries…

last idea: write a mini script to select three random numbers and check they are unique (can’t be too complex). Then use these for your three start items. Do the remaining images with smd_gallery.

Last edited by jakob (2008-05-21 18:07:42)


TXP Builders – finely-crafted code, design and txp

Offline

#59 2008-05-21 18:50:06

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_gallery: super-flexible gallery generator

Thanks jelle and jakob.

I’m going to be using slideshow by aeron (rloaderro)

probably going to manually call the script.

Offline

#60 2008-05-21 21:42:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: smd_gallery: super-flexible gallery generator

Dammit, trust you to find the limit of the plugin :-p

My take on this would be to drop back into PHP and do something like this (semi-untested) :

<txp:php>
$rs = safe_column("id", "txp_image", "category='your-chosen-category'");
$chosen = array_rand($rs,3);
for ($idx = 0; $idx < 3; $idx++) {
  $gal = array($chosen[$idx]);
  shuffle($rs);
  foreach ($rs as $row) {
    if ($row != $chosen[$idx]) {
      $gal[] = $row;
    }
  }

  $gal = join (",", $gal);
  $galNum = ($idx%2)+1;
  $ctr = $idx+1;
  echo smd_gallery(array(
    "id" => $gal,
    "form" => "galPart$galNum",
    "sort" => "fixed",
    "combo" => "uniq:$ctr",
    "collate" => "quote:{thumbdef}:{imagedef}:{alt}",
  ));
}
</txp:php>

That grabs the image IDs of all the pics in your pool, picks 3 at random, makes up 3 arrays from the shuffled IDs, making sure the 1st item is the one chosen at random and the rest follow without duplication. Then it makes the call to smd_gallery and tells it to use the list of IDs and keep the sort order fixed (since we’ve already shuffled them for each gallery).

Then proceed as per the slideshow example and make 2 forms (galPart1 and galPart2) to hold your thumb and image slideshows respectively. You’ll need some jiggery pokery to make sure the slideshows get unique IDs (hence the combo definition). So your galPart1 form might look like this (based on slideshow v1; not looked at v2 syntax yet) :

<div class="slideshow" id="slideshow{uniq#1}">
 <img src="<txp:site_url />images/{id#1}.jpg"
     alt="{alt#1}" width="{width#1}" height="{height#1}" />
</div>

<script type="text/javascript">
myShow1 = new Slideshow("slideshow{uniq#1}",
  { hu: "<txp:site_url />images/",
    images: [{thumbdef}],
    captions: [{alt}],
    classes: ["prev","next","active"],
    type: "fade"
  });
</script>

galPart2 is the same but with the {imagedef} replacement tag.

OK, it’s not quite the all-in-one you had hoped but it should work.

EDIT: Haven’t taken into account the different speeds but that’s down to slideshow, right? You could pick a random number between some upper and lower limit and assign it as a combo for use in the slideshow form?

Last edited by Bloke (2008-05-21 21:46:45)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB