Great Ocean Media
website design - editorial & pr services - freelance journalism

adi_join – Join stuff together

This plugin processes lines of code & joins their output together with separators.

Useful for creating comma-separated lists of data.


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

	...statement 1...
	...statement 2...
	...statement 3...

and, by default, the output will be:

statement 1 output, statement 2 output, statement 3 output



- the glue used to join your data together. Default = “, “.


- if you need a different separator for the last one. Default =”“ (none).


- the delimiter to distinguish the different chunks of the content. Default = newline.


- set to “1” to ensure that contained tags are not preparsed. Default = “0” (parse contained tags).


- set to “1” to strip out duplicates in the contained content. Default = “0” (allow duplicates).


- set to “1” to ensure that the last word of the sequence doesn’t appear on its own line. Default = “0” (allow widows).


- text to insert immediately before each item. Default = “” (no text inserted).


- text to insert immediately after each item. Default = “” (no text inserted).

sort="sort type"

- sort the items. Allowed sort types: ‘sort’,‘rsort’,‘natsort’,‘natcasesort’, ‘asc’, ‘desc’ (‘asc’ & ‘desc’ are equivalent to ‘sort’ & ‘rsort’). Default = not sorted.


- the (X)HTML tag (without ‘<>’ brackets) to wrap around each individual item in list, and their prefix/suffixes if present. Default = “” (none).


- some text to precede the list. Default = “” (no label). If there is no output then no label is generated.


- the (X)HTML tag (without ‘<>’ brackets) to wrap around the label. Default = “” (no tag).

label_class="class name"

- the class to be used on the label’s tag. Default = “” (none).

label_id="id name"

- the ID to be used on the label’s tag. Default = “” (none).


- the (X)HTML tag (without ‘<>’ brackets) to wrap around the whole list. Default = “” (none).

class="class name"

- the CSS class to be used on the wraptag. Default = “” (none).

html_id="id name"

- the HTML ID to be used on the wraptag. Default = “” (none).


To output article categories as a list:

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

If both categories are set, then the output is:

category 1 value, category 2 value

If only one catagory is set then only that category value is output. If neither categories are set then nothing is output.

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" />

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, then this:

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

will output:

My pithy&nbsp;slogan

To list items in brackets, then this:

<txp:adi_join prefix="(" suffix=")">

will output:

(one), (two), (three)

To wrap the whole list as well as individual items in tags, then this:

<txp:adi_join wraptag="p" itemtag="em">

will output:

<p><em>first</em>, <em>second</em>, <em>third</em></p>

Using a different delimiter:

<txp:adi_join separator=" - " delimiter="," wraptag="p">
	two, three

wil output:

<p>one - two - three - My pithy slogan</p>

To stop preparsing content, for example if there are delimiters inside tags which you don’t want to be interpreted as such:

<txp:variable name="comma_inside" value="comma,sandwich" />
<txp:adi_join separator=" - " delimiter="," ignore="1" wraptag="p">
	two, three
	<txp:variable name="comma_inside" />

will output:

<p>one - two - three - My pithy slogan - comma,sandwich</p>

Without the ignore="1" attribute, the output would’ve been:

<p>one - two - three - My pithy slogan - comma - sandwich</p>

Additional information

Support and further information can be obtained from the Textpattern support forum. A copy of this help is also available online. More adi_plugins can be found here.

adi_joinv0.3Download (Uncompressed) SupportTXP 4.5+