Index  Up  <<  >>  


loop

CALL INFORMATION
Parameters: list

Positional parameters in same order.

The attribute hash reference is passed after the parameters but before the container text argument. This may mean that there are parameters not shown here.

Must pass named parameter interpolate=1 to cause interpolation.

This is a container tag, i.e. [loop] FOO [/loop]. Nesting: NO

Invalidates cache: no

Called Routine:

ASP/perl tag calls:

    $Tag->loop(
        {
         list => VALUE,
        },
        BODY
    )
  
 OR
 
    $Tag->loop($list, $ATTRHASH, $BODY);

Attribute aliases

            arg ==> list
            args ==> list

 

DESCRIPTION
HTML example:

    <TABLE><TR MV="loop 1 2 3"><TD>[loop-code]</TD></TR></TABLE>

Returns a string consisting of the LIST, repeated for every item in a comma-separated or space-separated list. Operates in the same fashion as the [item-list] tag, except for order-item-specific values. Intended to pull multiple attributes from an item modifier -- but can be useful for other things, like building a pre-ordained product list on a page.

Loop lists can be nested reliably in MiniVend 3.06 by using the with=``tag'' parameter. New syntax:

    [loop arg="A B C"]
        [loop with="-a" arg="[loop-code]1 [loop-code]2 [loop-code]3"]
            [loop with="-b" arg="X Y Z"]
                [loop-code-a]-[loop-code-b]
            [/loop]
        [/loop]
    [/loop]

An example in the old syntax:

    [compat]
    [loop 1 2 3]   
        [loop-a 1 2 3 ]
        [loop-b 1 2 3]
            [loop-code].[loop-code-a].[loop-code-b]
        [/loop-b]
        [/loop-a]
    [/loop]
    [/compat]

All loop items in the inner loop-a loop need to have the with value appended, i.e. [loop-field-a name], [loop-price-a], etc. Nesting is arbitrarily large, though it will be slow for many levels.

You can do an arbitrary search with the search=``args'' parameter, just as in a one-click search:

    [loop search="se=Americana/sf=category"]
        [loop-code] [loop-field title]
    [/loop]

The above will show all items with a category containing the whole world ``Americana'', and will work the same in both old and new syntax.

[if-loop-data table field] IF [else] ELSE [/else][/if-loop-field]
Outputs the IF if the field in table is non-empty, and the ELSE (if any) otherwise.

[if-loop-field field] IF [else] ELSE [/else][/if-loop-field]
Outputs the IF if the field in the products table is non-empty, and the ELSE (if any) otherwise.

[loop-accessories]
Evaluates to the value of the Accessories database entry for the item.

[loop-change marker]
Same as [on_change] but within loop lists.

[loop-code]
Evaluates to the product code for the current item.

[loop-data database fieldname]
Evaluates to the field name fieldname in the arbitrary database table database, for the current item.

[loop-description]
Evaluates to the product description (from the products file) for the current item.

[loop-field fieldname]
Evaluates to the field name fieldname in the database, for the current item.

[loop-increment]
Evaluates to the number of the item in the list. Used for numbering items in the list.

[loop-last]tags[/loop-last]
Evaluates the output of the MiniVend tags encased inside, and if it evaluates to a numerical non-zero number (i.e. 1, 23, or -1) then the loop iteration will terminate. If the evaluated number is negative, then the item itself will be skipped. If the evaluated number is positive, then the item itself will be shown but will be last on the list.

      [loop-last][calc]
        return -1 if '[loop-field weight]' eq '';
        return 1 if '[loop-field weight]' < 1;
        return 0;
        [/calc][/loop-last]

If this is contained in your [loop list] and the weight field is empty, then a numerical -1 will be output from the [calc][/calc] tags; the list will end and the item will not be shown. If the product's weight field is less than 1, a numerical 1 is output. The item will be shown, but will be the last item shown.

[loop-next]tags[/loop-next]
Evaluates the output of the MiniVend tags encased inside, and if it evaluates to a numerical non-zero number (i.e. 1, 23, or -1) then the loop will be skipped with no output. Example:

      [loop-next][calc][loop-field weight] < 1[/calc][/loop-next]

If this is contained in your [loop list] and the product's weight field is less than 1, then a numerical 1 will be output from the [calc][/calc] operation. The item will not be shown.

[loop-price n* noformat*]
Evaluates to the price for optional quantity n (from the products file) of the current item, with currency formatting. If the optional ``noformat'' is set, then currency formatting will not be applied.


Index  Up  <<  >>