Textpattern CMS support forum

You are not logged in. Register | Login | Help

#281 2008-11-17 01:52:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,315
Website

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: 8,315
Website

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: 702
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: 8,315
Website

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: 702
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
Moderator
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: 8,315
Website

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

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

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 702
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: 8,315
Website

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

Board footer

Powered by FluxBB