Textpattern Forum

You are not logged in. Register | Login | Help

#371 2009-02-24 09:14:57

koobs
Member
Registered: 2008-11-25
Posts: 27

Re: smd_gallery: super-flexible gallery generator

Hi,

I set up smd_gallery at the weekend for a site and added lam_image_uploader to streamline the uploading of images for a very “unsavvy” client.

I’ve been really impressed with it so far but one thing is bugging me and wondering if anyone can help out?

I can’t seem to use a combination of integers and ranges in the article image field. eg: inputting “1-4, 5” will output only 1 & 5. Reading through the documentation it seems it should display 1,2,3,4,5.

Have I missed something

Thanks

Offline

#372 2009-02-24 10:11:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,979
Website

Re: smd_gallery: super-flexible gallery generator

koobs wrote:

inputting “1-4, 5” will output only 1 & 5

Yowzers! Confirmed bug in smd_lib. Thanks for finding that.

Here is some hold music…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#373 2009-02-24 11:25:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,979
Website

Re: smd_gallery: super-flexible gallery generator

OK, smd_lib is patched v0.35 (zipped)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#374 2009-02-24 11:37:46

koobs
Member
Registered: 2008-11-25
Posts: 27

Re: smd_gallery: super-flexible gallery generator

WOW! Top marks for a speedy bug fix

Thanks Stef

Offline

#375 2009-02-24 16:14:08

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_gallery: super-flexible gallery generator

Hi Bloke,
you may like to include the following tip as an example on plugin help. It’s an stripped down version of the one I posted on the faux bug report.
In fact, this can also be an example on smd_if plugin…

The following code will let you output rows of images, each row containing the same amount of images.
You may find it useful if you need to output rows of thumbnails (or any other thing), where each thumbnail has a different height. Usually, you may want to have thumbnails floated side by side, but if they have different heights, the output may get really messed.
Creating rows of images will let you float your thumbnails and then “clear” (applying overflow:hidden; height:100% to the row) the row, getting a tidier and neater output.

The following code will output rows of 3 images each row.

 <txp:smd_gallery category="animals">
<!-- we open the first row -->
  <txp:smd_if field="{counter}" operator="eq" value="1">
    <div class="photo-row">
  </txp:smd_if>

<!-- we start to spit the images -->
    <a href="{url}">
       <txp:thumbnail id="{id}" />
    </a>

<!-- if the counter is divisible by 3, and it's not the first image (1 = first loop) and it's not the last image ({totalimages} = last loop), close the row and open a new one -->
  <txp:smd_if field="{counter},{counter},{counter}" operator="divisible,not,not" value="3,1,{totalimages}">
    </div>
    <div class="photo-row">
  </txp:smd_if>

<!-- if this is the last image (last loop), close the div -->
  <txp:smd_if field="{counter}" operator="eq" value="{totalimages}">
    </div>
  </txp:smd_if>
  </txp:smd_gallery>

Bloke, feel free to revise it and do a re-wording of my explanation to fit your humorous style. :)

Edit: there was something wrong with the snippet: {maximages} will work fine if you aren’t using a limit attribute. But if you are using it, then results/maths won’t be as expected. It’s better to use {totalimages}, which matches the value of limit attribute (or, if not limit attribute, it matches the maximages value).

Last edited by maniqui (2009-02-25 05:55:01)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#376 2009-02-24 16:24:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,979
Website

Re: smd_gallery: super-flexible gallery generator

Nice example, thanks maniqui. I’ll see if I can shoe-horn it into either the smd_gallery or smd_if plugin help next time I update one of them.

On a pseudo-related note I haven’t decided how much the new thumbnail dimensions in the database will affect the plugin. Should make things a little simpler (perhaps faster) because I can just read the dimensions directly from the database instead of having to use PHP to discover the sizes. But it might have a wider impact on the plugin attributes, so I’ll leave the dust to settle for a while before I go any further.

Last edited by Bloke (2009-02-24 16:24:52)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#377 2009-02-24 16:38:55

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 477
Website

Re: smd_gallery: super-flexible gallery generator

Hey Julian,

Magic! I was scratching my head and pondering how to do almost exactly that when, ‘H E Y P R E S T O’, your post appeared. How do you do that? It’s uncanny.

Most grateful!

Joe

Offline

#378 2009-02-24 16:48:00

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_gallery: super-flexible gallery generator

You are welcome, Joe.
I must confess I borrowed the “algorithm” from a Django snippet at work.

Glad there exists smd_if and smd_gallery, so I could easily convert that snippet to TXP.
Bloke deserves all the credit.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#379 2009-02-24 17:26:18

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 477
Website

Re: smd_gallery: super-flexible gallery generator

Yep, the Bloke deserves much credit for all he does for the community. Smd_gallery has been a great enabler for me. I like the way you integrated smd_if with it. All the prizes aren’t awarded for originality; adaption is a great thing.

Slightly off the topic, did you know that Adrian Holovaty, co-inventor of Django, named it after Django Rheihardt, the legendary Belgian jazz guitarist? Like txp_bloke, Adrian is disgustingly talented too. I often wonder if I should have paid more attention at school, read more books or something.

Last edited by joebaich (2009-02-24 17:28:26)

Offline

#380 2009-02-25 05:58:59

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_gallery: super-flexible gallery generator

@joebaich:

there was something wrong with the snippet above: {maximages} will work fine if you aren’t using a limit attribute. But if you are using it, then results/maths won’t be as expected. It’s better to use {totalimages}, which matches the value of limit attribute (or, if not limit attribute, it matches the maximages value).

@Bloke:

could you please confirm that {totalimages} always equals the limit attribute? And, if no limit, then it’s equal to the total amount of images fetched/outputted?

Thanks.

Last edited by maniqui (2009-02-25 06:02:29)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB