Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#271 2008-11-11 12:32:15
- mcx
- Member
- Registered: 2008-11-11
- Posts: 12
Re: smd_gallery: super-flexible gallery generator
Oh and one other thing, I cannot seem to get clean URLs to work with my set-up and have reverted to the mess – not sure if this is possibly contributing the my “?id” problem.
Offline
#272 2008-11-11 12:51:57
Re: smd_gallery: super-flexible gallery generator
mcx wrote:
<txp:smd_gallery category=”?id” sublevel=“1” form=“gallery” debug=“1” />
Hmmm, well the sublevel=“1” isn’t necessary unless your image category contains subcats, but it won’t affect the output.
Your gallery form is fine, your head section is fine. This is where the problem lies:
txp_image.category = “smd_1053391178” ORDER BY txp_image.category asc
See that smd_ with random number attached? It does that when it cannot find the thing you specified in the category attribute (otherwise, if your category did not match anything it would show all images, which is not what you want).
From this I have two possible scenarios:
- You have not made an image category with the number of the article you are viewing
- The plugin cannot read the
idfor some reason
I doubt it’s number 1, since that’s the whole point of your system, but please double check that the image category name exactly matches the article ID. No spaces and stuff. It doesn’t matter if you have images in that category (well, it does if you want them to show up(!) but from a plugin functionality viewpoint it makes no difference, as it’ll just skip any empty categories).
For number 2, try this: set debug="4". You’ll see a tonne of crud on the screen but scan down to find AVAILABLE ‘?’ VARS and look at the ‘id’ attribute on the first line. That’s the ID of the current article you are viewing. If it’s blank, that’ll be the problem. You could try using category="?thisid" instead, though I can’t remember how that reacts on article list pages. When it works, you’ll see the very first bit of debug will show something like:
++ INCLUDED/EXCLUDED IDs AND CATs ++
array (
)
array (
)
array (
0 => '\'42\'',
)
Where 42 is the number of the current article ID.
If the ‘id’ is blank — either there or in the AVAILABLE ‘?’ VARS section — the next question is to find out why. For that I can’t think of any reason yet, but maybe when we’ve ruled out everything else we can start on that avenue if necessary. I don’t think clean URLs make any difference but I have never used them, hence the plugin has never been tested with them. It could well be that, I just don’t know at the moment.
Does that lot get you going anywhere other than circles?
Last edited by Bloke (2008-11-11 12:54:05)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#273 2008-11-11 14:13:06
- mcx
- Member
- Registered: 2008-11-11
- Posts: 12
Re: smd_gallery: super-flexible gallery generator
Thanks again for the speedy help. Will go through your suggestions and try things out.
As for going around in circles – It feels more productive than staring a screen that might as well be blank…
Last edited by mcx (2008-11-11 14:13:31)
Offline
#274 2008-11-11 14:23:11
- mcx
- Member
- Registered: 2008-11-11
- Posts: 12
Re: smd_gallery: super-flexible gallery generator
like a charm… basically, happened just like your reply – checked everything and still came up empty. Sprinkle a little four letter word on the mess and ta-da! Stef – thanks for “this” ;)
Offline
#275 2008-11-11 14:32:13
Re: smd_gallery: super-flexible gallery generator
mcx wrote:
Sprinkle a little four letter word on the mess and ta-da! Stef – thanks for “this” ;)
:-) No probs. Glad it’s sorted. I wonder if the fact that id is empty when thisid is populated has something to do with the clean url thing, or whether it is dependend on the URL scheme employed in Basic Prefs… *rhetorical pondering in progress*
Either way I’ll have to document thisid. I’ve done it in other plugins so it’s only fair.
Last edited by Bloke (2008-11-11 14:33:38)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#276 2008-11-16 21:56:07
- curiouz
- Member

- Registered: 2006-06-20
- Posts: 56
Re: smd_gallery: super-flexible gallery generator
Hi Bloke,
I tried setting the delim to '_,_', like you suggested, but this causes the combo to be parsed wrong:
combo="test|'{imagedef}': {caption:'{title}'_,_href:'{somecombo}'}"
is parsed as:
'1.jpg': {caption:'bla'_,_href:'bla'};
Last edited by curiouz (2008-11-16 22:00:33)
Offline
#277 2008-11-16 22:38:06
Re: smd_gallery: super-flexible gallery generator
curiouz wrote:
I tried setting the delim to
'_,_', like you suggested, but this causes the combo to be parsed wrong:
Hehe, sorry, my instructions were a tad ambiguous last time. I actually meant to set delim="_,_" and then change every other occurrence of plain commas into _,_ but leave the one in the combo alone.
For example if you had:
category="cat1, cat2, cat3" id="?custom1, 42"
that should read:
category="cat1_,_cat2_,_cat3" id="?custom1_,_42" delim="_,_"
The delim option governs which characters are used to split regular attributes (comma by default). Overriding it means you have to change everywhere you’d normally use a comma to use your new sequence of characters instead. Then the combo itself is free to use the comma unhindered. Does that make sense?
However, when I just tried it I found an unforeseen problem with this approach: if you use my (foolishly chosen) sequence of characters _,_ and put the smd_gallery tag in an article, guess what? Textile gets in the way and converts the comma into an italicized comma, thus the whole tag breaks! The solution if you are using it in an article is of course to either turn off Textile processing or use a better delimiter. The double colon works well, I tried it and the combo renders fine with all other commas in other attributes replaced with ::.
Sorry for not making myself clear earlier. I assure you it works but if you still have problems, post your full smd_gallery tag and I’ll see if I can figure out what’s going wrong.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#278 2008-11-16 23:34:23
- curiouz
- Member

- Registered: 2006-06-20
- Posts: 56
Re: smd_gallery: super-flexible gallery generator
Thanks for the quick reply! Still not working though.
Changing delim to ::, also affects the splitting of attributes in the script tag, so:
<txp:smd_gallery category="slideshow" form="slideshow" collate="{test}" combo="test|'{imagedef}': {caption:'{title}', href:'{alt}'}" paramdelim="|" delim="::"/>
is parsed as:
var data = {'3.jpg': {caption:'bla', href:'bla'}::'4.jpg': {caption:'bla2', href:'bla2'}
I use this form:
<div id="slideshowwrap">
<div class="slideshow" id="show">
<img src="<txp:site_url />images/{id#1}.jpg" alt="{alt#1}" />
</div>
</div>
<script type="text/javascript">
var data = {{test}};
var myShow1 = new Slideshow('show', data,
{controller: true, hu: 'http://jonasdesign.nl/concept/energielive/images/', width: 50, height: 65, duration: 800, delay: 8000,loader:false,paused:false,captions:{duration: 800}, linked:true});
</script>
Offline
#279 2008-11-17 00:28:40
Re: smd_gallery: super-flexible gallery generator
curiouz wrote:
Changing delim to
::, also affects the splitting of attributes in the script tag
Oh bollocks, you’re totally right. I didn’t test it with collate mode on. Sorry about that, here’s me saying it’s working and it plainly isn’t :-(
Try v0.46 | zipped which adds the collatedelim attribute. That allows you to specify what you want to put between collated items (instead of it stupidly using delim like it did before). The default is a comma so you should be good to go without any extra attributes required. Thanks for your patience at getting this problem through my thick skull.
I also took the opportunity to (hopefully once and for all) fix the bug nardo reported, that resulted in duplicate IDs. It was a hangover from me attempting to fix the bug that robin746 found a few posts before. Many thanks to all who have highlighted bugs in my slapdash code!
Last edited by Bloke (2008-11-17 00:29:56)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#280 2008-11-17 01:24:15
- curiouz
- Member

- Registered: 2006-06-20
- Posts: 56
Re: smd_gallery: super-flexible gallery generator
I really appreciate all your help! thanks a lot!
I still can’t get the combo to be parsed right though. The href part of the following combo:
combo="test|'{imagedef}': {caption:'{title}', href:'{alt}'}"
isn’t parsed when I use a comma between caption:'{title}' and href:'{alt}'. When I use :: there, the href part does get parsed… I can’t set collatedelim to something else, because then the splitting of attributes in the script tag won’t be right. So I think what I need is an option that replaces a custom delimiter between combo tags to a comma (combodelim maybe??)… man, this is getting complicated…
Offline
#281 2008-11-17 01:52:43
Re: smd_gallery: super-flexible gallery generator
curiouz wrote:
I still can’t get the combo to be parsed right though.
combo="test|'{imagedef}': {caption:'{title}', href:'{alt}'}"isn’t parsed
Hmmm, I’m officially confused because it’s parsing for me. At least I think it’s working…
OK, let’s go back to square one. What do you need to generate? i.e. what is the format of the output that Slideshow2 requires (I’ve never made one so I don’t really know)? We can then work back from there to figure out what options you need to set in order to make it work.
For the record, here is a tag that works for me (but note my combo has href:'{url}' not href:'{alt}') :
<txp:smd_gallery category="slideshow" collate="1" combo="test|'{imagedef}': {caption:'{title}', href:'{url}'}" paramdelim="|" delim="::">
<div id="slideshowwrap">
<div class="slideshow" id="show">
<img src="<txp:site_url />images/{id#1}.jpg" alt="{alt#1}" />
</div>
</div>
<script type="text/javascript">
var data = {{test}};
var myShow1 = new Slideshow('show', data, {controller: true, hu: 'http://site.com/whatever/', width: 50, height: 65, duration: 800, delay: 8000, loader:false, paused:false, captions:{duration: 800}, linked:true});
</script>
</txp:smd_gallery>
What I get out is this:
<div id="slideshowwrap">
<div id="show" class="slideshow">
<img alt="" src="http://site.com/images/12.jpg"/>
</div>
</div>
<script type="text/javascript">
var data = {'12.jpg': {caption:'Superduper caption', href:'http://site.com/images/12.jpg'},'20.jpg': {caption:'Some caption junk', href:'http://site.com/images/20.jpg'},'45.jpg': {caption:'Another caption', href:'http://site.com/images/45.jpg'}};
var myShow1 = new Slideshow('show', data, {controller: true, hu: 'http://site.com/whatever/', width: 50, height: 65, duration: 800, delay: 8000, loader:false, paused:false, captions:{duration: 800}, linked:true});
</script>
The only thing I can think that might be killing the parser is if there are unescaped quotes or apostrophes in your caption or alt fields. That may well cause things to go sideways.
Spookily enough, I did think of adding a combodelim attribute when I went to v0.46, but couldn’t see the immediate benefit since the delimiter can be specified manually in the combo itself. If it proves necessary though, I’ll certainly add it.
But like I say, let’s go back to basics, work backwards from the output that Slideshow requires then see if we can get this going for you.
Last edited by Bloke (2008-11-17 01:53:59)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#282 2008-11-18 13:28:00
- curiouz
- Member

- Registered: 2006-06-20
- Posts: 56
Re: smd_gallery: super-flexible gallery generator
Hi Bloke! The combo parsed correctly!
Wrapping the code within the smd_gallery tag somehow fixed it.
Before I had the smd_gallery tag in my page and the rest in a form..
You’re awesome! thanks a lot!
Offline
#283 2008-11-18 13:57:58
Re: smd_gallery: super-flexible gallery generator
curiouz wrote:
You’re awesome! thanks a lot!
No probs. Glad it’s working now.
Wrapping the code within the smd_gallery tag somehow fixed it.
Urk, well if that’s the case I’d better investigate whether there’s any difference between the parsing of a container vs a form. I hope there isn’t (it’s the same code!) but maybe I’ve stuffed something up somewhere along the line. I’ll take a look, thanks for the insight.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#284 2008-11-26 12:59:26
Re: smd_gallery: super-flexible gallery generator
Everything is working fine only I can’t get the sort attribute working in smd_gallery … !?
This is the site/page > www.gunnardaan.nl/txp/ien and it works with Shadowbox.
smd_gallery:
<txp:smd_gallery category="ien" form="gallery" sort="category asc" />
form:
<a href="{url}" title="{title}" rel="shadowbox[gallery]"><img class="thumb" src="<txp:site_url/>images/{thumbdef}" alt="{alt}" /></a>
Thanks for any help.
Last edited by RedFox (2008-11-26 13:02:39)
Offline
#285 2008-11-26 13:31:38
Re: smd_gallery: super-flexible gallery generator
RedFox wrote:
I can’t get the
sortattribute working in smd_gallery … !? …<txp:smd_gallery category="ien" form="gallery" sort="category asc" />
Not sure I follow. With only one category being extracted in your tag it can’t order by category — since there is only one!
If you had three categories of thumbnails in a single gallery (for example showing all images from categories called ien, twa and trije) then sort="category asc" would display all the images from the ien category then all the images from trije then finally from twa; it orders by category name, alphabetically.
If instead you want the images to be ordered within a category you must choose something else to sort by (e.g. "id asc" or "date asc").
Does that help, or have I missed the point?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline