For more information... RTFM!
NAVIGATION
RECENTLY VIEWED
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

PREFIX-change

Summary

  • [PREFIX-change marker][condition] VALUE [/condition] TEXT [/PREFIX-change marker]

Description

Sets up a breaking sequence that occurs when the contents of the [condition] VALUE [/condition] change.  The most common use is a category break to nest or place headers.

The region is only output when a field or other repeating value between [condition] and [/condition] changes value.  This allows indented lists similar to database reports to be easily formatted.  The repeating value must be a tag interpolated in the search process, such as [PREFIX-field] or [PREFIX-field table column].  If you need access to Interchange tags then you can use [PREFIX-calc] with a $Tag-foo() (Perl) call.

Of course, this will only work as you'd expect if the search results are properly sorted.

The "marker" parameter is mandatory, and is also arbitrary;  Any "marker" can be selected, as long as the name same name is used in both the start and end tags.

The value to be tested is contained within a [condition] VALUE [/condition] tag pair.  The [PREFIX-change] tag also processes an optional "[else]...[/else]" block, which can be used to output some text when the VALUE has not changed.

Here is a simple example for a search list that has a field category and subcategory associated with each item:

<table>
    <tr>
        <th>Category</th>
        <th>Subcategory</th>
        <th>Product</th>
    </tr>
[search-list]
    <tr>
        <td>
[item-change cat]
[condition][item-field category][/condition]
            [item-field category]
[else]
            &nbsp;
[/else]
[/item-change cat]
        </td>
        <td>
[item-change sub]
[condition][item-field subcategory][/condition]
            [item-field subcategory]
[else]
            &nbsp;
[/else]
[/item-change sub]
        </td>
        <td>
            [item-field name]
        </td>
[/search-list]
</table>

The above should put out a table that only shows the category and subcategory once, while showing the name for every product.  The "&nbsp;" will prevent "empty" cells from messing up the table display.

You should also know that this loop sub-tag will nest.  For example:

Nested blocks example

[item-change foo]
[condition][item-param category][/condition]
    ...

    [item-change bar]
    [condition][item-param prod_group][/condition]

        ...

    [/item-change bar]

    ...
[/item-change foo]

Closing tag syntax

The closing tag syntax is slightly different from most other container tags.  Most container tags use a format such as "[tagname params]...[/tagname]", whereas this loop sub-tag uses "[tagname param]...[/tagname param]".  For example:

Valid

[item-change foo]
[condition][item-param category][/condition]
   ...
[/item-change foo]
Invalid (no closing marker)

[item-change foo]
[condition][item-param category][/condition]
   ...
[/item-change]
Invalid (opening and closing markers don't match)

[item-change foo]
[condition][item-param category][/condition]
   ...
[/item-change bar]

Category:  Looping tags and sub-tags
Last modified by: Paul Jordan
Modification date: Tuesday 29 August 2006 at 3:22 PM (EDT)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us