Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-11-01 23:42:56

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,167
Website

adi_join - Join stuff together

Summary

adi_join is a simple little thing to join stuff together. Useful for creating comma-separated lists of data.

See the help supplied with the plugin, or have a look online. You can download the latest version from here.

Usage

Simply put the adi_join tag around the output you need joined:

<txp:adi_join>
	...statement 1...
	...statement 2...
	...statement 3...
</txp:adi_join>

and, by default, the result will be:

statement 1 output, statement 2 output, statement 3 output

adi_join takes the hassle out of worrying about if there’s some data & whether a comma is needed.

Examples

To output article categories as a list:

<txp:adi_join>
	<txp:category1 />
	<txp:category2 />
</txp:adi_join>

If both categories are set, then the output is:

category 1 value, category 2 value

To output a series of variables separated by commas but with an ampersand at the end:

<txp:adi_join last_separator=" & ">
	<txp:variable name="var1" />
	<txp:variable name="var2" />
	<txp:variable name="var3" />
</txp:adi_join>

If all variable are non-blank then the output will be:

var1 value, var2 value & var3 value

And even if you just want to prevent a widow on something:

<txp:adi_join no_widow="1">
	<txp:site_slogan />
</txp:adi_join>

will output:

My pithy&nbsp;slogan

Requirements

Simple enough to work in most versions of Textpattern.

Version history

  • 0.3
    • new attributes: ‘delimiter’, ‘ignore’ (for pieman)
    • new attribute: ‘unique’
    • TXP 4.6 tag registration
  • 0.2
    • new attributes: prefix, suffix, itemtag (for jakob)
    • new attribute: sort (for milosevic)
    • new attributes: ‘label’, ‘labeltag’, ‘label_class’, ‘label_id’
  • 0.1
    • initial release

Feedback

Comments are most welcome.

Spread the love

If you find this plugin useful and would like a warm and fuzzy feeling to go with it, please consider donating to the Textpattern development team.

Last edited by gomedia (2015-06-15 12:38:17)

Offline

#2 2011-11-02 07:51:38

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 2,578
Website

Re: adi_join - Join stuff together

Handy! That cuts out a lot of the if_first / smd_counter / nested if_category gymnastics. Nice that you can define a custom normal and end separators, e.g. for chaining &urlvars or outputting csv syntax or for using “or” instead of “and” or “, and” with a comma to please our US colleagues :-)

What about an option to wrap each contained item in something, e.g. “quotes”, (brackets) or <xml> open and closing tags </xml>? Currently I use rah_repeat or smd_each for this.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2011-11-02 11:37:41

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,167
Website

Re: adi_join - Join stuff together

jakob wrote:

Handy!

Yes, it’s one of those simple things that’s fiddly to achieve.

What about an option to wrap each contained item in something, e.g. “quotes”, (brackets) or <xml> open and closing tags </xml>? Currently I use rah_repeat or smd_each for this.

Yep, that can be done. WRT wrap tags, do you want <xml>(item)</xml> or (<xml>item</xml>)?

Offline

#4 2011-11-02 12:47:49

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 2,578
Website

Re: adi_join - Join stuff together

gomedia wrote:

Yep, that can be done. WRT wrap tags, do you want <xml>(item)</xml> or (<xml>item</xml>)?

Gulp, not sure I follow. I just meant wrap the individual items with something that could conceivably have a different opening and closing forms. I guess if you those are user-definable, you can determine the order yourself if you need double wrappers…


TXP Builders – finely-crafted code, design and txp

Offline

#5 2011-11-02 19:41:33

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 380

Re: adi_join - Join stuff together

Congrats, nice and simple! I will love to see a “sort” param for sorting de output (asc, desc)


<txp:rocks/>

Offline

#6 2011-11-02 20:14:18

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,167
Website

Re: adi_join - Join stuff together

jakob wrote:

Gulp, not sure I follow.

I was wondering if you wanted any wrapping brackets or quotes, inside or outside the wrapping <xml></xml> tags.

Offline

#7 2011-11-02 20:14:53

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,167
Website

Re: adi_join - Join stuff together

milosevic wrote:

Congrats, nice and simple! I will love to see a “sort” param for sorting de output (asc, desc)

I’ll look into it.

Offline

#8 2011-11-02 21:22:26

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: adi_join - Join stuff together

jakob wrote:

Gulp, not sure I follow.

gomedia wrote:

I was wondering if you wanted any wrapping brackets or quotes, inside or outside the wrapping <xml></xml> tags.

I am sure Jabob would like to have the Common Presentational Attributes. Not sure what else could be added :)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#9 2011-11-03 11:17:53

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 458
Website

Re: adi_join - Join stuff together

<txp:adi_join separator="">

very useful for working with display=inline-block css mode and <txp:variables> in if_data mode

Thanks Adi

Offline

#10 2011-12-12 22:27:05

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,167
Website

Re: adi_join - Join stuff together

Version 0.2 ready for download:

  • new attributes: prefix, suffix, itemtag (for jakob)
  • new attribute: sort (for milosevic)
  • new attributes: ‘label’, ‘labeltag’, ‘label_class’, ‘label_id’

Offline

Board footer

Powered by FluxBB