Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#661 2010-04-02 18:21:08

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

Re: smd_gallery: super-flexible gallery generator

jan wrote:

is it possible to display just ‘the latest album’?

Hmmm, I don’t think you can do it in one hop. Simplest way I can think of, if you have smd_query installed, is to extract the most recent category using that plugin, assign it to a variable and then use that variable’s name in your smd_gallery:

<txp:variable name="latest_album"><txp:smd_query query="SELECT category FROM txp_image ORDER BY date DESC LIMIT 1">{category}</txp:smd_query></txp:variable>

<txp:smd_gallery category="?latest_album">
   ...
</txp:smd_gallery>

Someone with more cunning or a better grasp of SQL/plugins might be able to find another way to order the images and grab the category in one, but I can’t think of a method offhand. I don’t even think upm_image can do it, and nor can the recent native image_list tag.

EDIT: actually you can do it in one loop if you’re not going to be employing paging. It’s a bit messy and requires smd_if:

<txp:variable name="latest_album" value="" />
<txp:smd_gallery sort="date desc">
   <txp:smd_if field="{counter}" value="1">
      <txp:variable name="latest_album">{category}</txp:variable>
   </txp:smd_if>
   <txp:smd_if field="{category}, {counter}" value="?latest_album, 1" logic="or">
      // gallery output goes here
   </txp:smd_if>
</txp:smd_gallery>

Last edited by Bloke (2010-04-02 18:28:44)


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

#662 2010-04-02 23:43:40

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: smd_gallery: super-flexible gallery generator

Is there attr break_class?


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#663 2010-04-03 09:56:40

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

Re: smd_gallery: super-flexible gallery generator

the_ghost wrote:

Is there attr break_class?

v0.61 has breakclass yes :-) Thanks for the nudge; no idea why I missed that all these years.


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

#664 2010-04-03 14:46:52

jan
Member
From: Utrecht, The Netherlands
Registered: 2006-08-31
Posts: 71
Website

Re: smd_gallery: super-flexible gallery generator

Thanks a lot Bloke, the combination with smd_query worked like a charm! Indeed an extra query, but that’s no huge problem.


Kensington TXP powered rock

Offline

#665 2010-04-06 00:11:08

jan
Member
From: Utrecht, The Netherlands
Registered: 2006-08-31
Posts: 71
Website

Re: smd_gallery: super-flexible gallery generator

I have another small issue. It seems the {grouptagend} replacement tag isn’t working correctly (or I’m doing something wrong).
The problem is that each category begins with <ul class=“album”> (like I want), but isn’t closed with a closing </ul> tag. The </ul> tag isn’t put in until the plugin has iterated over all categories/images.

Is there perhaps something wrong with this code:

<txp:smd_gallery 
      category="!SMD_EMPTY"
      grouptag="ul"
      groupclass="album"
      onchange="category_title"
      onchangewraptag="h2"
      onchangeclass="noborder">
      {onchange:category_title}
      {grouptagstart}
      <li>
        <a href="{url}" rel="{category}"><img src="{thumburl}" alt="{alt}" /></a>
      </li>
      {grouptagend}
</txp:smd_gallery>

Thanks very much in advance!


Kensington TXP powered rock

Offline

#666 2010-04-06 16:32:10

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

Re: smd_gallery: super-flexible gallery generator

jan wrote:

Is there perhaps something wrong with this code:

Nope, it’s a stupid bug I introduced in v0.6. Thanks for pointing it out, though at the moment I can’t see a way of getting round it.

For background reference, it’s to do with the way the category_title is figured out. I used to join the category table with the images table so I knew everything about all the images up-front. But that caused all sorts of annoying problems so I reverted to the ‘safe’ method of simply looking up the category title for each image as it was encountered.

The problem stems from the way I figure out if the current onchange item is about to change. By the time the next image has been reached it’s too late to output the {groupendtag} so I have to make it available on the current image. Thus I have to “look ahead” to see if the onchange thing is going to alter on the next image and if it does, trigger the {groupendtag} to be added to the container so you can use it. Unfortunately I don’t know the next image’s category title until I actually get to that image and read its properties — since I had the entire record set available to me in prior versions of the plugin I could make a cheeky lookahead to the next ‘row’ to find out if the category title is different from what it is now.

Not sure if any of that makes sense, but the upshot is this only affects category_title. A workaround is this ugly kludge which does the onchange on category (name, not title), assigns the category name to a txp:variable and then, if and only if that variable exists, uses the txp:category tag to look up and display the category title:

<txp:smd_gallery 
     category="!SMD_EMPTY"
     grouptag="ul"
     groupclass="album"
     onchange="category">
   <txp:variable name="theCat" value="{onchange:category}" />
   <txp:if_variable name="theCat" value="">
      <txp:hide>Same category as before: do nothing</txp:hide>
   <txp:else />
      <txp:category name='<txp:variable name="theCat" />' title="1" type="image" wraptag="h2" class="noborder" />
   </txp:if_variable>
   {grouptagstart}
   <li>
     <a href="{url}" rel="{category}"><img src="{thumburl}" alt="{alt}" /></a>
   </li>
   {grouptagend}
</txp:smd_gallery>

Note I’ve moved the onchangewraptag and onchangeclass to the txp:category tag as well. If you keep them in the smd_gallery tag the {onchange:category} replacement has them already applied to the string so you can’t look the raw name up! *sheesh*

I’ll try and work on a fix for this one. I don’t much like the look-ahead anyway so I’ll see if I can figure out a better way.

Last edited by Bloke (2010-04-06 16:35:27)


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

#667 2010-04-06 18:00:34

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

Re: smd_gallery: super-flexible gallery generator

Oh alright, I’ll just cheat and make the lookahead even more unpalatable in v0.62. Try that.


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

#668 2010-04-06 20:02:20

eivl
Member
Registered: 2009-04-09
Posts: 20

Re: smd_gallery: super-flexible gallery generator

Hello Stef, i use a old plugin named rss_auto_excerpt, when i use it with your gallery and if auto excerpt kicks in, article listening breaks down.

I know that it is rss_auto_excerpt fault, but i dont know how to correct it. do you have any ideas?

Offline

#669 2010-04-06 22:14:00

jan
Member
From: Utrecht, The Netherlands
Registered: 2006-08-31
Posts: 71
Website

Re: smd_gallery: super-flexible gallery generator

That solved it, Stef! (With the exact same markup as I posted when I stated the problem) Thanks so much!


Kensington TXP powered rock

Offline

#670 2010-04-09 19:08:38

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: smd_gallery: super-flexible gallery generator

  1. Does {thumbwidth/height} and can output real size of thumb?
  2. And may be it worth to make analogue of php’s @getimagesize@

array getimagesize ( string $filename [, array &$imageinfo ] )
Index 3 is a text string with the correct height=“yyy” width=“xxx” string that can be used directly in an IMG tag.


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#671 2010-04-26 19:39:51

Scott Girvan
Member
Registered: 2010-04-14
Posts: 10

Re: smd_gallery: super-flexible gallery generator

Wondering if there are any tutorials out there for adding pagination to the gallery, specifically when using it as a ‘single thumbnail display > slimbox popup’ style. As seen here: www.scalemodeladdict.com/gallery

Thanks again for pointing me in the right direction.
Scott.

Offline

#672 2010-04-26 19:56:51

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

Re: smd_gallery: super-flexible gallery generator

Scott Girvan wrote:

Wondering if there are any tutorials out there for adding pagination to the gallery

Not tutorials as such no; just the plugin examples. If you’re doing that kind of one thumb -> multi image lightbox thing (very nicely done, btw) then limit is no good to you. My guess is that you’re using {object}, right? And possibly objectform? If so, how about trying the thumblimit attribute?

If I’ve done my job properly that should still switch paging on, still render all your group images, but stop rendering when it reaches N thumbnails. You can then use pageform and the paging replacement tags to add your nav bar. Plenty of examples in the help on that bit.

Be interesting to know if that works. And if it doesn’t I’ll damn well have a go at fixing the plugin so it does!

Last edited by Bloke (2010-04-26 19:57:27)


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