Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2008-11-16 22:38:06

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

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.

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

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

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.

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

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

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.

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

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

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#284 2008-11-26 12:59:26

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

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

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

Re: smd_gallery: super-flexible gallery generator

RedFox wrote:

I can’t get the sort attribute 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.

Txp Builders – finely-crafted code, design and Txp

Offline

#286 2008-11-26 15:45:07

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

Re: smd_gallery: super-flexible gallery generator

Thanks Bloke for making this clear to me.

Btw … is it possible to embed cno_image_order in smd_gallery by putting sort="position asc" into the tag? Well, I know, it doesn’t work, but is it because of smd_gallery or cno_image_order? Do you know this plug-in? It would be great if it does the job with yours … :)

Last edited by RedFox (2008-11-26 15:46:37)

Offline

#287 2008-11-26 16:05:43

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

Re: smd_gallery: super-flexible gallery generator

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.

Bloke, now that the new parser accepts tags-in-tags, do you think there is any benefit on using txp style tags for your plugin?
Probably, it may be overkilling, right?

But, at the same time, there are some benefits on using txp/xml tag styles, like the possibility of having attributes on the tags.
Particularly, {title} (that renders the caption, if i’m not wrong) can’t be escaped. upm_image offers that functionality.
Of course, there may be no need to have txp tags just for the sake of having attributes (which, btw, may not be needed at all). Maybe just a {title_esc} can do the job.

Bloke, I’m not asking anything here, just posting the idea to be discarded if it’s not good at all (someone has to bring the bad ideas to the surface, and that’s usually my task here at forums, ;) ).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#288 2008-11-26 16:06:15

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

Re: smd_gallery: super-flexible gallery generator

RedFox wrote:

Thanks Bloke for making this clear to me.

No Probs.

is it possible to embed cno_image_order in smd_gallery by putting sort="position asc" into the tag?

Not at the moment but you can make it work (I think, untested) by going into the plugin code and adding 1 line. Look right at the top for the block that starts:

	$fieldMap = array(
		"txp_image.name" => "name",
		"txp_image.id" => "id",
...

Add a row before the closing ); that reads:

"txp_image.position" => "position",

And it should then be available for use. Not sure if that impacts anything else but I don’t think so because I designed it that way so it’s fairly easy to add new fields when/if they were added to the core.


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