![]() |
| > Home > Documentation > Latest documentation > Interchange tags > loop |
|
loopSummary
The following parameters are also available to this tag:
See the search parameters page for more parameters. Note that you must use the two-character short code, rather than the full name, with parameters listed on that page. Here is a quick list of some of the search parameters that are useful in this context:
ExamplesTag usage example
DescriptionLoops through the template, contained this tag's the body text, for every item in the comma-separated or space-separated list. Operates in the same fashion as the [item-list] tag, except for order-item-specific values. This tag is intended to allow you to pull multiple attributes from an item modifier, but can be useful for other tasks, such as building a pre-ordained product list on a page. Loop lists can be nested reliably by using the "prefix=whatever" parameter. For example:
You can initiate an arbitrary search with the use of the search="args" parameter, just as you would with a one-click search. For example:
The above will show all items with a category containing the whole word "Americana". Ranges are accepted, when you pass a list, if you set the ranges parameter, as follows:
Any Perl incrementing variable list will work, but most commonly a range would look something like "1..100". You can also mix sets. For instance, "1..5 10 20" would produce the list "1 2 3 4 5 10 20". If you surround the repeating text section with a [list][/list] container, then [more-list] and [on-match] processing (etc.) can be performed just the same as with the [query] and [search-region] tags. A nice shortcut is available when using the [loop] tag to generate <option> lists inside HTML <select> lists, when you want the user's last selection to be chosen by default on subsequent page views. Interchange simplifies this with a sub-tag that outputs "selected="selected"" (surrounded by appropriate whitespace) for an <option> if a certain value is set to the <option value="...">. It sounds more complicated than it really is. For example, consider the following:
When the user returns to the page, their last selection will be chosen as the default, assuming that the search_cat value was set after the search, which is normally the case with standard searches. The order in which the list is displayed can be influenced by using the [sort] pseudo-tag. ParameterslistComma-separated list of items to iterate through. The list can include ranges, such as "1..10", if the ranges parameter is true. The list will be treated as a "key=value" option list if the acclist parameter is true. acclistUsing the acclist parameter will cause this tag to treat the list as an option list, with items in the "key=value" format, as sometimes used in product options. The value is available with [loop-code] and the label with [loop-param label]. For instance, if the size data for product code TS-007 was set to "S=Small, M=Medium, L=Large, XL=Extra Large", then you could produce a <select> list of options like this:
Of course, the above is probably more easily produced with [accessories code="TS-007" attribute="size"], but there will always be other uses for the capability, such as:
delimiterOverride the column separator character. If the lr parameter is true then the default separator is a tab character (\t). If the lr parameter is false then the default separator is one or more commas (,) whitespace characters. The delimiter can be expressed as a regular expression, such as the default "[,\s]+" expression. extendedRead Table::Editor metadata using this parameter's value, which is expected to be in the "view::table::key" format. extended_onlyfileReads the list from the named file, which must be relative to the website's home directory (as specified using the Catalog global configuration directive). If this parameter is used then the lr parameter will be set true to allow the file content to be parsed as a series of rows and columns. Set "lr=0" to override this behaviour. head_skipThis parameter is only useful if lr and/or file is in use, and the list is filled with multiple rows. Head_skip pulls rows off the top of the list, and uses the last row pulled to set the column names. All of the columns will be made available for use with the [loop-param] sub-tag. lrIf this parameter is true then the list is treated as if it has multiple rows as well as multiple columns. Rows are separated with the record_delim character ("\n" by default), and columns are separated with the delimiter character ("\t" by default). The first column will be made available for use with the [loop-code] sub-tag. All of the columns will be made available for use with the [loop-pos] sub-tag. See also head_skip. moreYou must set "more=1" to properly paginate results from list queries. If you do not set "more=1", then [more-list] links to later pages will merely redisplay the first page of your results. objectrangesAllow the list to contain ranges, such as "1..10", which would be taken to mean "one through ten".
record_delimThis parameter is used to override the default row separator, which is an ASCII LF character (\n), and is only used if the lr parameter is set true. searchInitiate an arbitrary search, just as you would with a one-click search. quotedIf your list needs to have spaces in the individual items, then surround them with double or single quotes and set this parameter true. formYou can use this to pass one or more form variables in the pagination links of a [more-list]. For example, use form="foo=bar" to include "foo=bar", as a URI argument in each of the pagination links.
labelIf you are setting up multiple simultaneously-active search objects within a page, then this allows you to distinguish between them. The default label is "current". Most people will not need this. more_templateOverride the default display template value, used by the [more-list] sub-tag. prefixSetting "prefix=foo" overrides the "PREFIX" used by the various [PREFIX-*] sub-tags, and also by the [PREFIX-quote] container. The default "prefix" is "loop". safe_dataSetting "safe_data=1" allows the [sql-data] and [sql-param] sub-tag (etc.) to return values containing the "[" character.
|
| Home | Legal nonsense | Privacy policy | Contact us |