split

Based on the delimiter specified, will split out content into an array

Example

[%split delimiter:','%]
    [%param data1%]author1,author2,author3,author4[%/param%]
    [%param data2%]book1,book2,book3,book4[%/param%]
    [%param *header%]
        [@count@] is the number of items.
    [%/param%]
    [%param *body%]
        <p>[@data1@] is the author of [@data2@]</p>
    [%/param%]
    [%PARAM *footer%]
    [%/param%]
[%/split%]

Usage

The split tag will look at a set of data in a parameter then use Neto's body tag format to allow for you to generate HTML around that data set. In the example shown above we take a number of authors and books, use the delimiter param to identify the , which then creates two data sets we print in the body tag using the corresponding data1 and data2 data tags into a paragraph.

Note: If using two data sets and one of them is longer than the first then the shorter one will return empty strings after its last array variable is returned and the longer string will keep returning until the max size is reached.

Note: the delimiter param can take the form of any value you might need. However, some values like " will only be interpreted if the param is specified as a block. E.g:

[%split delimiter:','%]
    [%param data1%]author1,author2,author3,author4[%/param%]
    [%param data2%]book1,book2,book3,book4[%/param%]
    [%param *header%]
        [@count@] is the number of items.
    [%/param%]
    [%param *body%]
       <p>[@data1@] is the author of [@data2@]</p>
    [%/param%]
    [%param *footer%]
    [%/param%]
[%/split%]

Parameters

Name Options Description
`delimiter:''` `,`, `;`, `|`, `&`, `=`, etc Determine what character defines each set of data from the `data` param. This parameter can take the form of any value.
`data1:''`, `data2:''`, `data3:''`, `data4:''`, etc HTML & b@se The set of data to process into the `data1`, `data2`, etc data tags for the `body` param. At least one is required.
`*header` HTML & b@se tags Renders a single usable space above the body
`*body` HTML & b@se tags Runs an array for each option in the tag
`*footer` HTML & b@se tags Renders a single usable space below the body
`ifempty:''`, `*ifempty` HTML & b@se tags If the type selected has no content pages, it will display this content
Name Example Description
`[@count@]`, `[@total_results@]` 4 Total number of results

Data Tags (body)

Name Example Description
`[@count@]` 0 Increments each time the tag is run - starting with `0`
`[@data1@]`, `[@data2@]`, `[@data3@]`, `[@data4@]`, etc author1 Prints the data collected in the `data1`, `data2`, `data3`, `data4`, etc param

Was this article useful?

Be notified when this page is updated. Optional.