Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#289 2008-11-26 16:23:31

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 782
Website

Re: smd_gallery: super-flexible gallery generator

Bloke … it is working. This one is a real timesaver if you have to reorder a lot of images. Thank you so much!

Offline

#290 2008-11-26 16:40:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,577
Website GitHub

Re: smd_gallery: super-flexible gallery generator

maniqui wrote:

I like the {...} syntax of this plugin, because it makes code more readeable than tags-in-tags.
But at the same time, it feels a bit un-textpatternish.

I know what you mean. When I rewote my image patch recently I thought it would be cool to have an smd_gallery tag in that vein:

<txp:smd_gallery_info name="some_bit_of_info" />

(e.g. id, caption, date) which would do the same thing as the {...} syntax. It’s doable, it’s more typing for you, it allows exactly the same output except from a coding point of view it’s uglier because it means having a global variable defined to keep track of which image you are currently viewing.

On article list pages this becomes even more fun because if you were to put the main gallery tag in the <head> of your page and then try and display info from each article in a form later on, you’d see the same info over and over again for the “first” gallery that the plugin hit. To you and me that’s obvious because we know how TXP operates but to my mind, that actually makes the plugin more confusing than it already is for people starting out… mind you if anyone’s just starting out and discovers smd_gallery they’ll probably not stick around Textpattern very long anyway!

From a coding standpoint it just requires extra checks to see if the tag you are using is within a valid <txp:smd_gallery /> tag container/form. The fun then starts when you want different things from different tags, e.g. you want a formatted date out instead of the contents of the title field. The title or caption has a very different demographic (for want of a better word) than a date; as you mention, a caption needs an attribute escape whereas a date might need a format.

Adding all possible attributes to a single tag <txp:smd_gallery_info /> tag is going to cause chaos. Making one per item is too bloaty. One per ‘type’ is possible but then you have to remember the type of thing you want and use the appropriate tag. For instance, <txp:smd_gallery_text name="caption" escape="html" /> vs <txp:smd_gallery_date format="Y m d" /> (does that need escaping?) vs <txp:smd_gallery_link link="1" type="thumbnail" /> and so on.

I think the reason I still to this day get confused with upm_image is because everything has its own tag and I forget whether it’s upm_image_img_url or just upm_image_url etc. It’s the “correct” method (in the TXP way of doing things) but also confusing (to me) because they’re named similarly and attributes I think should be in one tag aren’t there because they’re in the parent tag, or some other child tag. Perhaps it’s just me.

I’m not denying that smd_gallery has problems: it does. Lack of MLP is one. Lack of escaping and formatting of the output is another if there is no tag or plugin you can use to do that function. Because remember there’s nothing to stop you embedding the {...} inside another tag:

<txp:smd_gallery category="cat1, cat2">
  <a href="{url}" title='<txp:escape_me value="{title}" />'>{name}</a>
</txp:smd_gallery>

Or perhaps some formatting tag to translate the date from a UNIX timestamp into something useful. I’m not sure if that works, but it might be a better direction for this plugin to take: what if I made such tags part of smd_gallery? Would that get too confusing? Or maybe Gocom will make us some super-cool generic escaping and formatting plugin(s)? ;-)

I don’t know the answer. If you were going to do it, how would you approach it from an end-user perspective? What makes sense to you and is a good compromise between the (massive) amount of info that smd_gallery can output vs the usability of a good set of tags and the ability to customise the output better?

EDIT: btw, the {...} concept is wet’s fault: he started it :-D

Last edited by Bloke (2008-11-26 17:02:23)


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

#291 2008-12-04 13:07:52

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_gallery: super-flexible gallery generator

Hi Bloke,
thanks for the detailed reply.
I’ve nothing to add, the genius is you, not me.

Now, the question: is it possible to assign an id (I’m talking about the HTML attribute here) to the wraptag? I’ve seen it’s possible to use the class attribute, but I didn’t find a way to use an id.
It could be useful for javascripting purposes.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#292 2008-12-04 17:14:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,577
Website GitHub

Re: smd_gallery: super-flexible gallery generator

maniqui wrote:

is it possible to assign an id

Yes it’s possible. Yes it’s easy. Yes it’ll be in the next revision.


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

#293 2008-12-04 17:21:27

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_gallery: super-flexible gallery generator

Yes, yes, yes :)

Possibilities with this plug-in seem almost endless.

Just for the sake of posting a very simple example:

<txp:article_custom id="1">
... some txp article tags...
  <txp:smd_gallery id="?article_image">
     <txp:image id="{id}" />
  </txp:smd_gallery>
</txp:article_custom>

It’s like upm_image on steroids.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#294 2008-12-04 17:57:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,577
Website GitHub

Re: smd_gallery: super-flexible gallery generator

maniqui

The new attribute will be html_id to fit in with the other core tags that use one, and it’ll apply it to the wraptag only, yes? (if it’s used). You can sort of simulate it now if you like. Look at this, untested, example:

<txp:article limit="10">
   <h3><txp:title /></h3>
   <txp:smd_gallery id="?article_image" combo="myhtml_id:mydiv_?thisid">
      <txp:smd_if field="{counter}" operator="eq" value="1">
         <div id="{myhtml_id}">
      </txp:smd_if>

         <txp:image id="{id}" />

      <txp:smd_if field="{counter}" operator="eq" value="{totalimages}">
         </div>
      </txp:smd_if>
   </txp:smd_gallery>
</txp:article>

That will (should!) create a combo for every article and label it mydiv_ plus the article’s ID. The smd_if tags make sure the opening and closing divs are only displayed on the first and last images (assuming article_image holds more then one image).

Obviously the tag attribute html_id simplifies this ten-fold! Thanks for the idea.


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

#295 2008-12-04 18:38:11

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_gallery: super-flexible gallery generator

Hey, in that case (using the smd_gallery inside an article) it is far less easier to create a unique ID ;)

<txp:article limit="10">
   <h3><txp:title /></h3>
   <txp:smd_gallery id="?article_image">
      <txp:smd_if field="{counter}" operator="eq" value="1">
         <div id="mydiv_<txp:article_id />">
      </txp:smd_if>

         <txp:image id="{id}" />

      <txp:smd_if field="{counter}" operator="eq" value="{totalimages}">
         </div>
      </txp:smd_if>
   </txp:smd_gallery>
</txp:article>

My request was for when you don’t have a way to generate a unique identifier (i.e. when using smd_gallery outside txp:article). The html_id attr will be helpful.

And the smd_if trick for opening/closing divs is a good one too.

Thanks Bloke!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#296 2008-12-11 08:11:41

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 858
Website

Re: smd_gallery: super-flexible gallery generator

Bloke – you are my hero :)

Superb plugin – Thanks

Offline

#297 2008-12-11 17:17:09

mlarino
Member
Registered: 2007-06-29
Posts: 367

Re: smd_gallery: super-flexible gallery generator

Hi,
I am having a problem launching the slimbox gallery form one image.

The page has 4 different images that open 4 different galleries.
Sketchbook1 (opens sketchbook1 category images in slimbox)
Sketchbook2 (opens sketchbook2 category images in slimbox) etc…

All this works, each one opens the slimbox in the first image from their category, but the problem is that instead of stoping in their category, you can view every image from the rest of categories.

the code I have in the page is:

<txp:smd_gallery category=“sketchbook_paris” id=”?article_image” sublevel=“0” form=“gallery” thumblimit=“1” />

<txp:smd_gallery category=“sketchbook_2008” id=”?article_image” sublevel=“0” form=“gallery” thumblimit=“1” />

<txp:smd_gallery category=“sketchbook_2007” id=”?article_image” sublevel=“0” form=“gallery” thumblimit=“1” />

<txp:smd_gallery category=“sketchbook_2007” id=”?article_image” sublevel=“0” form=“gallery” thumblimit=“1” />

Offline

#298 2008-12-11 18:44:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,577
Website GitHub

Re: smd_gallery: super-flexible gallery generator

mlarino wrote:

instead of stoping in their category, you can view every image from the rest of categories.

You need to add something to the rel= attribute to stop the images from all being in the same “group”.

By default all images that have “lightbox” in their rel become one big group of images when you launch the lightbox. If you add something to the end of the rel that is unique to that particular gallery, you will only be able to navigate within that group.

Since you are only showing one category per smd_gallery, the category is in ideal candidate. So add:

rel="lightbox-{category}"

to the anchor in your gallery form. When you look at the page source you’ll see that all images in the first gallery have:

<a rel="lightbox-sketchbook_paris" id="...">

and ones in the next gallery have:

<a rel="lightbox-sketchbook_2008" id="...">

and so on.


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

#299 2008-12-15 17:14:27

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: smd_gallery: super-flexible gallery generator

Bloke:

Hope all is well on your side of the pond.

I was wondering, have you ever come across a lightbox image viewer that has the capability to Auto Play when launched. The reason I ask, is that I have a client that really likes the flexibility of lightbox (ie not boxed into a set image size for a complete gallery) but they want it to play like a slideshow without requiring user input (but also having the flexability to require user input if they want.)

I have searched, but have not found such an anmial yet.

Any input from Bloke (or anyone on the board) would be much appreciated.

progre55

Offline

#300 2008-12-15 18:33:16

keith
Member
From: Blyth, Northumberland, England
Registered: 2004-12-08
Posts: 199
Website

Re: smd_gallery: super-flexible gallery generator

What about this one? I’m sure that smd_gallery will work with it.

Example here


Keith
Blyth, Northumberland, England
Capture The Moment

Offline

Board footer

Powered by FluxBB