Download the PHP package rah/rah_repeat without Composer
On this page you can find all versions of the php package rah/rah_repeat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rah/rah_repeat
More information about rah/rah_repeat
Files in rah/rah_repeat
Package rah_repeat
Short Description Iterator tags for Textpattern CMS templates
License GPL-2.0
Homepage https://github.com/gocom/rah_repeat
Informations about the package rah_repeat
h1. rah_repeat
"Download":https://github.com/gocom/rah_repeat/releases | "Packagist":https://packagist.org/packages/rah/rah_repeat | "Issues":https://github.com/gocom/rah_repeat/issues
Adds iterator template tags to "Textpattern CMS":https://textpattern.com. The plugin splits provided values to smaller chunks and iterates overs, just like you would expect from a for each loop in any programming language. With the plugin you can turn a simple comma-separated list of values into advanced HTML output, or extract parts of a value as "variables":https://docs.textpattern.com/tags/variable.
h2. Install
Using "Composer":https://getcomposer.org:
bc. $ composer require rah/rah_repeat
Or "download":https://github.com/gocom/rah_repeat/releases an installer package.
h2. Basics
bc.
Rah_repeat's main job is primely iterating over values. Its iteration power can used to create lists or extract subsets of data. The plugin can come very handy when you have a "custom field":https://docs.textpattern.com/tags/custom_field that contains comma-separated list of values which you want to present as a HTML list or extract as individual separate values.
The values you want to iterate over are provided to the tag with the @value@ attribute, each individual subset value separated from each other with the @delimiter@, defaulting to a comma. The current value that is being iterated over can be returned using the @rah::repeat_value@ tag, wrapped in @rah::repeat@ block. The following would generate a HTML list from comma-separated list of @red, blue, green@.
bc.
</rah::repeat>
In addition to iterating over values and creating lists, the tag can also be used to extract values and assign each one to a "variable":https://docs.textpattern.com/tags/variable tag. This can be done using the @rah_repeat@ tag's @assign@ attribute. The attribute takes a comma-separated list of variable names that will be created, each containing one of the values.
bc.
The above would extra each of the colors as a variable. These variables would be named as @color1@, @color2@ and @color3@. Using @
h2. Tags and attributes
The plugin comes with a total of four tags. The main tag @rah::repeat@, a single tag @rah::repeat_value@, and two conditionals @rah::repeat_if_first@ and @rah::repeat_if_last@.
h3. rah::repeat
bc.
The @
value Sets the values that are passed to the tag. Multiple values are separated with the @delimiter@ which by default is a comma (@,@). If @range@ is set to @1@, individual values can declare dash-separated value ranges, e.g. @1-5, 8, 24-81, 9, 15@. Either this attribute or @range@ is required. Example: @value="dog, cat, human"@ Default: @""@
range Creates a list of values containing a range of elements, or if set to boolean @1@, enables the value ranges feature in the @value@ attribute. Using @range@ to create a list of values overrides @value@ attribute. It works identically to PHP's "range":https://secure.php.net/manual/en/function.range.php function and uses same sequence syntax as it. The attribute's value consists of three parts: @minimum@, @maximum@ and @step@, each separated by a comma. All but @step@ are required. If the @range@ is set to @1@, it enables similar feature in the @value@ attribute's individual delimiter-separated values. Example: @range="1, 10"@ Default: undefined
delimiter Sets the delimiter that is used to split the provided @value@ into a list. Default delimiter is comma (@,@). Example: @delimiter="|"@ Default: @","@
assign Assigns values as Textpattern's "variables":https://docs.textpattern.com/tags/variable. Takes a comma-separated list of variable names: @variable1, variable2, variable3, ...@. Example: @assign="label, value"@ Default: @unset@
duplicates Removes duplicate values from the list. If the attribute is set to @1@, only first occurrence of the value is used and duplicates are stripped off. Example: @duplicates="1"@ Default: @"0"@
exclude Exclude certain values from the list. The attribute takes a comma (or @delimiter@, if @delimiter@ is changed) separated list of values. Example: @exclude="foo,bar"@ Default: undefined
trim Trims values from extra whitespace. This can be particularly helpful if the provided values are from user-input (e.g. from an article field), or the values just have extra whitespace, and the resulting output has to be clean (i.e. used in XML, JavaScript or to a "variable":https://docs.textpattern.com/tags/variable comparison). If you want to keep whitespace intact, you can use this attribute. By default the option is on, and values are trimmed. Example: @trim="0"@ Default: @"1"@
sort Sorts the values. If the attribute is used, all values are rearranged to the specified order. Available options are @regular@ (sorts without checking the type), @numeric@ (sorts in a numeric order), @string@ (sorts as strings) and @locale_string@ (sorts according server's locale settings). All the values can be followed by the sorting direction, either @desc@ and @asc@. By default the option isn't used (unset), and the values are returned in the order they were supplied. Example: @sort="regular asc"@ Default: @""@
offset The number of items to skip. Default is @0@ (none). Example: @offset="5"@ Default: @"0"@
limit The number of items are displayed. By default there is no limit, and all items are returned. Example: @limit="10"@ Default: undefined
form Use specified form partial. By default contained statement is used instead of a form. Example: @form="price_column"@ Default: @""@
wraptag The (X)HTML tag (without brackets) used to wrap the output. Example: @wraptag="div"@ Default: @""@
break The (X)HTML tag (without brackets) or a string used to separate list items. Example: @"break="br"@ Default: @""@
class The (X)HTML class applied to the @wraptag@. Default is unset. Example: @class="plugin"@ Default: @""@
h3. rah::repeat_value
bc.
</rah::rah_repeat>
Rah_repeat_value a single tag, used to display a iterated value. The tag should be used inside a @
escape If set to @1@, HTML and Textpattern markup are escaped, and special characters are converted to HTML entities. By default this option is off. Example: @escape="1"@ Default: @"0"@
index If set to @1@, the tag returns the iterated value's index number. The index starts from 0. Example: @index="1"@ Default: @"0"@
h3. rah::repeat_count
bc.
Returns the number of items in the last @rah::repeat@ loop. This tag works similarly to the "search_result_count":https://docs.textpattern.com/tags/search_result_count.
h3. rah::repeat_if_first
bc.
- A dog.
- A cat.
- A butterfly.
Some text here.
Some another cool phrase here.
- group1
- item1
- item2
- group2
- item1
- item2
- First: item1
- item2
- item3
- item4
- Last: item5