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.

Usage

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

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

and, by default, the output will be:

statement 1 output, statement 2 output, statement 3 output

Attributes

separator="text"

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

last_separator="text"

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

delimiter="text"

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

ignore="boolean"

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

unique="boolean"

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

no_widow="boolean"

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

prefix="text"

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

suffix="text"

- 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.

itemtag="tag"

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

label="text"

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

labeltag="tag"

- 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).

wraptag="tag"

- 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).

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

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

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

will output:

My pithy&nbsp;slogan

To list items in brackets, then this:

<txp:adi_join prefix="(" suffix=")">
	one
	two
	three
</txp:adi_join>

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">
	first
	second
	third
</txp:adi_join>

will output:

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

Using a different delimiter:

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

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">
	one,
	two, three
	,<txp:site_slogan/>,
	<txp:variable name="comma_inside" />
</txp:adi_join>

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.

Version 0.3 - Download (Uncompressed) Support