.\" Automatically generated by Pod::Man version 1.15
.\" Wed May 5 11:41:33 2004
.\"
.\" Standard preamble:
.\" ======================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
.\" to do unbreakable dashes and therefore won't be available. \*(C` and
.\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr
.\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
.\" index entries marked with X<> in POD. Of course, you'll have to process
.\" the output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it
.\" makes way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
.bd B 3
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ======================================================================
.\"
.IX Title "ictags 8"
.TH ictags 8 "Interchange 5.2.0" "2004-05-05" "Interchange"
.UC
.SH "NAME"
ictags \- Interchange Tags Reference
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
.SH "Interchange Tag Reference"
.IX Header "Interchange Tag Reference"
Interchange functions are accessed via the Interchange Tag Language
(\s-1ITL\s0). The pages in a catalog may be mostly \s-1HTML\s0, but they will use
\&\s-1ITL\s0 tags to provide access to Interchange's functions. \s-1ITL\s0 is a
superset of \s-1MML\s0, or Minivend Markup Language. Minivend was the
predecessor to Interchange.
.PP
These tags perform various display and modification operations for the
user session. There nearly 100 standard predefined tags, and the
UserTag facility allows you to create tags that perform your own
functions and can be just as powerful as the built-in tags.
.PP
This document covers Interchange versions 4.7 through 4.9.
.SH "Tag Syntax"
.IX Header "Tag Syntax"
\&\s-1ITL\s0 tags are similar to \s-1HTML\s0 in syntax, in that they accept parameters
or attributes and that there are both \fIstandalone\fR and \fIcontainer\fR
tags.
.PP
We will call an attribute a \fIparameter\fR if it may be called
positionally or if it must be included (see the \fIparameter\fR and
\&\fIattribute\fR sections below).
.PP
A standalone tag has no ending element, e.g.:
.PP
.Vb 1
\& [value name]
.Ve
This tag will insert the user's name, providing they have given it to
you in a form. A container tag has both a beginning and an ending
element, as in:
.PP
.Vb 3
\& [if value name]
\& You have a name. It is [value name].
\& [/if]
.Ve
.Sh "Standard Syntax"
.IX Subsection "Standard Syntax"
The most common syntax is to enclose the tag with its parameters and
attributes in [square brackets]. If the tag has an end tag, the tag
and its end tag will delimit contained body text:
.PP
.Vb 1
\& [tagname parameters attributes]Contained Body Text[/tagname]
.Ve
\&\fBCaveat \- macros: \fRSome macros look like tags or end tags. For
example, [/page] is a macro for . This allows you to
conveniently write [page \fIhref\fR]Target[/page], but 'Target' is
not treated as contained body text.
.PP
When using the [tagname ...] syntax, there must be no whitespace
between the left bracket ('[') and the tagname.
.PP
If a tag name includes an underscore or dash, as in [\fIitem_list\fR], a
dash is just as appropriate (i.e. [item-list]). The two forms are
interchangeable, except that an ending tag must match the tag (i.e.,
don't use [item-list] list [/item_list]).
.Sh "HTML-Comment"
.IX Subsection "HTML-Comment"
\&\s-1ITL\s0 also allows you to use '' as interchangeable
alternatives to plain square brackets: [tagname] and
\&\f(CW\*(C`\*(C'\fR are equivalent.
.PP
This allows you make your raw tags appear as comments to \s-1HTML\s0 browsers
or editors. You might want to do this if your editor has trouble with
\&\s-1ITL\s0 tags when editing Interchange page templates, or alternatively, if
you want to use one .html file both as an Interchange template and as
a static page delivered directly by your web server, without
Interchange processing.
.PP
To properly HTML-comment contained body text, place your comment-style
brackets appropriately, for example:
.PP
.Vb 1
\&
.Ve
Note that you must include whitespace between the \s-1HTML\s0 comment
delimiters and the square brackets if you wish to actually comment out
tag output in the browser. For example, if [value name] expands to
\&'Bill':
.PP
.Vb 2
\& '' becomes 'Bill'
\& '' becomes ''
.Ve
Technical notes
.PP
While '' with ']' unless it also sees 'routine( { search => $arrayref, } );
.Ve
Similarly to use a hash reference for the 'entry' attribute:
.PP
.Vb 2
\& my $hashref = { name => "required",
\& date => 'default="%B %d, %Y"', };
.Ve
.Vb 1
\& $Tag->routine( { entry => $hashref } );
.Ve
.SH "Looping tags and Sub-tags"
.IX Header "Looping tags and Sub-tags"
Certain tags are not standalone; these are the ones that are
interpreted as part of a surrounding looping tag like [\fIloop\fR],
[\fIitem-list\fR], [\fIquery\fR], or [\fIsearch-region\fR].
.Ip "" 4
[\fIPREFIX-accessories\fR]
.Sp
[\fIPREFIX-alternate\fR]
.Sp
[\fIPREFIX-calc\fR]
.Sp
[\fIPREFIX-change\fR]
.Sp
[\fIPREFIX-code\fR]
.Sp
[\fIPREFIX-data\fR]
.Sp
[\fIPREFIX-description\fR] (Note safe-data and \fIed()\fR escape)
.Sp
[\fIPREFIX-discount\fR]
.Sp
[\fIPREFIX-discount-subtotal\fR]
.Sp
[\fIPREFIX-field\fR] (Optimization note\-\- one query per field if you use
this; we optimize around this if only one products table)
.Sp
[\fIPREFIX-increment\fR]
.Sp
[\fIPREFIX-last\fR]
.Sp
[\fIPREFIX-line\fR] (tab-delimited list of parameters returned)
.Sp
[\fIPREFIX-modifier\fR]
.Sp
[\fIPREFIX-next\fR]
.Sp
[\fIPREFIX-param\fR]
.Sp
[\fIPREFIX-pos\fR]
.Sp
[\fIPREFIX-price\fR]
.Sp
[\fIPREFIX-quantity\fR]
.Sp
[\fIPREFIX-subtotal\fR]
.Sp
[\fIif-PREFIX-data\fR]
.Sp
[\fIif-PREFIX-field\fR]
.Sp
[if-PREFIX-param]
.Sp
[if-PREFIX-pos]
.Sp
[\fImodifier-name\fR]
.Sp
[\fIquantity-name\fR]
.PP
\&\s-1PREFIX\s0 represents the prefix that is used in that looping tag. They
are only interpreted within their container and only accept positional
parameters. The default prefixes:
.PP
.Vb 5
\& Tag Prefix Examples
\& [loop] loop [loop-code], [loop-field price], [loop-increment]
\& [item-list] item [item-code], [item-field price], [item-increment]
\& [search-list] item [item-code], [item-field price], [item-increment]
\& [query] sql [sql-code], [sql-field price], [sql-increment]
.Ve
Sub-tag behavior is consistent among the looping tags. Subtags are
parsed during evaluation of the enclosing loop, \fIbefore\fR any regular
tags within the loop.
.PP
There are two types of looping lists: \s-1ARRAY\s0 and \s-1HASH\s0.
.PP
An array list is the normal output of a [query], a search, or a
[loop] tag. It returns from 1 to N return fields, defined in the
mv_return_fields or rf variable or implicitly by means of a \s-1SQL\s0
field list. The two queries below are essentially identical:
.PP
.Vb 2
\& [query sql="select foo, bar from products"]
\& [/query]
.Ve
.Vb 5
\& [loop search="
\& ra=yes
\& fi=products
\& rf=foo,bar
\& "]
.Ve
Both will return an array of arrays consisting of the foo column
and the bar column. The Perl data structure would look like:
.PP
.Vb 6
\& [
\& ['foo0', 'bar0'],
\& ['foo1', 'bar1'],
\& ['foo2', 'bar2'],
\& ['fooN', 'barN'],
\& ]
.Ve
A hash list is the normal output of the [item-list] tag. It returns
the value of all return fields in an array of hashes. A normal
[item-list] return might look like:
.PP
.Vb 15
\& [
\& {
\& code => '99-102',
\& quantity => 1,
\& size => 'XL',
\& color => 'blue',
\& mv_ib => 'products',
\& },
\& {
\& code => '00-341',
\& quantity => 2,
\& size => undef,
\& color => undef,
\& mv_ib => 'products',
\& },
.Ve
.Vb 1
\& ]
.Ve
You can also return hash lists in queries:
.PP
.Vb 2
\& [query sql="select foo, bar from products" type=hashref]
\& [/query]
.Ve
Now the data structure will look like:
.PP
.Vb 6
\& [
\& { foo => 'foo0', bar => 'bar0' },
\& { foo => 'foo1', bar => 'bar1' },
\& { foo => 'foo2', bar => 'bar2' },
\& { foo => 'fooN', bar => 'barN' },
\& ]
.Ve
.Sh "PREFIX-accessories"
.IX Subsection "PREFIX-accessories"
.Vb 1
\& [PREFIX-accessories arglist]
.Ve
Except for the usual differences that apply to all subtags (such as
parsing order), these are more or less equivalent for an array-type
list:
.PP
.Vb 2
\& [accessories code=current_item_code arg=arglist]
\& [item-accessories arglist]
.Ve
See the [accessories] tag for more detail. Note that you must use
the comma-delimited list to set attributes \- you cannot set named
attributes with the usual 'attribute=value' syntax.
.PP
If the list is a hash list, i.e. an [item-list], then the value of
the current item hash is passed so that a value default can be
established.
.Sh "PREFIX-alternate"
.IX Subsection "PREFIX-alternate"
.Vb 1
\& [PREFIX-alternate N] DIVISIBLE [else] NOT DIVISIBLE [/else][/PREFIX-alternate]
.Ve
Set up an alternation sequence. If the item-increment is divisible by
`N', the text will be displayed. If an `[else]NOT \s-1DIVISIBLE\s0
TEXT[/else]' is present, then the \s-1NOT\s0 \s-1DIVISIBLE\s0 \s-1TEXT\s0 will be
displayed.
.PP
For example:
.PP
.Vb 2
\& [item-alternate 2]EVEN[else]ODD[/else][/item-alternate]
\& [item-alternate 3]BY 3[else]NOT by 3[/else][/item-alternate]
.Ve
There are some additional primitives:
.PP
.Vb 7
\& Tag Description
\& [item-alternate first_only] Only true on first item
\& [item-alternate last_only] Only true on last item
\& [item-alternate except_last] True except on last item
\& [item-alternate except_first] True except on last item
\& [item-alternate 0] Same as "first_only"
\& [item-alternate -1] Same as "except_last"
.Ve
In the common case where you want to separate by a comma or other
joiner:
.PP
.Vb 4
\& You have the following items:
\& [item-list]
\& [item-code][item-alternate except_last], [/item-alternate]
\& [/item-list]
.Ve
.Sh "PREFIX-calc"
.IX Subsection "PREFIX-calc"
.Vb 1
\& [PREFIX-calc] 2 + [item-field price] [/PREFIX-calc]
.Ve
Executes Perl code in the tag body. This is equivalent to the
[calc] ... [/calc] tag pair, except it's calculated at loop time
instead of later when the rest of the page is parsed.
.Sh "PREFIX-change"
.IX Subsection "PREFIX-change"
.Vb 1
\& [PREFIX-change][condition] ... [/condition] TEXT [/PREFIX-change]
.Ve
Sets up a breaking sequence that occurs when the contents of
[condition] [/condition] change. The most common one is a category
break to nest or place headers.
.PP
The region is only output when a field or other repeating value
between [condition] and [/condition] changes its 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 database field]. If you
need access to \s-1ITL\s0 tags, you can use [PREFIX-calc] with a
\&\f(CW$Tag\fR-\fIfoo()\fR> call.
.PP
Of course, this will only work as you expect when the search results
are properly sorted.
.PP
The value to be tested is contained within a
[condition]value[/condition] tag pair. The [PREFIX-change] tag
also processes an [else] [/else] pair for output when the value
does not change.
.PP
Here is a simple example for a search list that has a field
category and subcategory associated with each item:
.PP
.Vb 6
\&
.Ve
The above should put out a table that only shows the category and
subcategory once, while showing the name for every product. (The
will prevent blanked table cells if you use a border.)
.Sh "PREFIX-code"
.IX Subsection "PREFIX-code"
.Vb 1
\& [PREFIX-code]
.Ve
The key or code of the current loop. In an [item-list] this is
always the product code; in a loop list it is the value of the current
argument; in a search it is whatever you have defined as the first
mv_return_field (rf).
.Sh "PREFIX-data"
.IX Subsection "PREFIX-data"
.Vb 1
\& [PREFIX-data table field]
.Ve
Calls the column field in database table table for the current
[PREFIX-code] This may or may not be equivalent to [PREFIX-field
field] depending upon whether your search table is defined as one of
the ProductFiles.
.Sh "PREFIX-description"
.IX Subsection "PREFIX-description"
.Vb 1
\& [PREFIX-description]
.Ve
The description of the current item, as defined in the catalog.cfg
directive DescriptionField. In the demo, it would be the value of
the field description in the table products.
.PP
If the list is a hash list, and the lookup of DescriptionField
fails, then the attribute description will be substituted. This is
useful to supply shopping cart descriptions for on-the-fly items.
.Sh "PREFIX-discount"
.IX Subsection "PREFIX-discount"
.Vb 1
\& [PREFIX-discount]
.Ve
The price of the current item is calculated, and the difference
between that price and the list price (quantity one) price is output.
This may have different behavior than you expect if you set the
[discount] tag along with quantity pricing.
.Sh "PREFIX-discount-subtotal"
.IX Subsection "PREFIX-discount-subtotal"
.Vb 1
\& [PREFIX-discount-subtotal]
.Ve
Inserts the discounted subtotal of the ordered items.
.Sh "PREFIX-field"
.IX Subsection "PREFIX-field"
.Vb 1
\& [PREFIX-field]
.Ve
Looks up a field value for the current item in one of several places,
in this order:
.PP
.Vb 4
\& 1. The first ProductFiles entry.
\& 2. Additional ProductFiles in the order they occur.
\& 3. The attribute value for the item in a hash list.
\& 4. Blank
.Ve
A common user error is to do this:
.PP
.Vb 4
\& [loop search="
\& fi=foo
\& se=bar
\& "]
.Ve
.Vb 2
\& [loop-field foo_field]
\& [/loop]
.Ve
In this case, you are searching the table foo for a string of
bar. When it is found, you wish to display the value of
foo_field. Unless foo is in ProductFiles and the code is not
present in a previous product file, you will get a blank or some value
you don't want. What you really want is [loop-data foo field],
which specifically addresses the table foo. See also
[PREFIX-param] and [PREFIX-pos].
.Sh "PREFIX-increment"
.IX Subsection "PREFIX-increment"
.Vb 1
\& [PREFIX-increment]
.Ve
The current count on the list, starting from either 1 in a
zero-anchored list like [loop] or [item-list], or from the match
count in a search list.
.PP
If you skip items with [PREFIX-last] or [PREFIX-next], the count
is \s-1NOT\s0 adjusted.
.Sh "PREFIX-last"
.IX Subsection "PREFIX-last"
.Vb 1
\& [PREFIX-last] CONDITION [/PREFIX-last]
.Ve
If \s-1CONDITION\s0 evaluates true (a non-whitespace value that is not
specifically zero) then this will be the last item displayed.
.Sh "PREFIX-line"
.IX Subsection "PREFIX-line"
.Vb 1
\& [PREFIX-line start_column]
.Ve
Returns all array values from the current looping row in a single
string, with each value separated by a tab, roughly equivalent to
this:
.PP
.Vb 1
\& [PREFIX-pos 0](tab)[PREFIX-pos 1](tab)[PREFIX-pos 2](tab)[...]
.Ve
for however many fields were returned in that row.
.PP
This is useful as a quick way to see all your results at a glance and
verify your search specification.
.PP
If the optional start_column attribute is given, the output starts
with that column instead of column 0.
.Sh "PREFIX-modifier"
.IX Subsection "PREFIX-modifier"
.Vb 1
\& [PREFIX-modifier attribute]
.Ve
If the item is a hash list (i.e. [item-list]), this will return the
value of the attribute.
.Sh "PREFIX-next"
.IX Subsection "PREFIX-next"
.Vb 1
\& [PREFIX-next] CONDITION [/PREFIX-next]
.Ve
If \s-1CONDITION\s0 evaluates true (a non-whitespace value that is not
specifically zero) then this item is skipped.
.Sh "PREFIX-param"
.IX Subsection "PREFIX-param"
.Vb 1
\& [PREFIX-param name]
.Ve
Returns the value of the column name associated with the looping tag
row. Each looping list returns an array of return fields, set in
searches with mv_return_field or rf. The default is only to
return the code of the search result, but by setting those parameters
you can return whichever columns you wish.
.PP
In a [query] \s-1ITL\s0 tag you can select multiple return fields with
something like:
.PP
.Vb 3
\& [query prefix=prefix sql="select foo, bar from baz where foo='buz'"]
\& [prefix-code] [prefix-param foo] [prefix-param bar]
\& [/query]
.Ve
In this case, [prefix-code] and [prefix-param foo] are synonyms, as
foo is the first returned parameter and becomes the code for this
row. Another synonym is [prefix-pos 0].
.PP
Mixed case field names in your \s-1SQL\s0 tables will be forced to lower case
in the [prefix-param name] tag if the underlying Database does that
(as with most \s-1SQL\s0 types). For example if your query is
.PP
.Vb 1
\& [query prefix=prefix sql="select Foo, Bar from baz where Foo='buz'"]
.Ve
then you must use:
.PP
.Vb 1
\& [prefix-param foo] and [prefix-param bar]
.Ve
to display your results, rather than:
.PP
.Vb 1
\& [prefix-param Foo] and [prefix-param Bar]
.Ve
Note that the following code is invalid:
.PP
.Vb 9
\& [query prefix=prefix sql=|
\& SELECT table1.foo,
\& table2.bar
\& FROM table1, table2
\& WHERE table1.code = table2.code
\& AND table1.foo = 'buz'
\& |]
\& [prefix-param table1.foo] [prefix-param table2.bar]
\& [/query]
.Ve
The problem with the above code is that \s-1DBI\s0 doesn't support column
names such as table1.foo in its resultsets. The following query
syntax is fully supported by \s-1DBI\s0 and therefore by Interchange:
.PP
.Vb 9
\& [query prefix=prefix sql=|
\& SELECT table1.foo AS foo,
\& table2.bar AS bar
\& FROM table1, table2
\& WHERE table1.code = table2.code
\& AND table1.foo = 'buz'
\& |]
\& [prefix-param foo] [prefix-param bar]
\& [/query]
.Ve
.Sh "PREFIX-pos"
.IX Subsection "PREFIX-pos"
.Vb 1
\& [PREFIX-pos N]
.Ve
Returns the value of the array parameter associated with the looping
tag row. Each looping list returns an array of return fields, set
in searches with mv_return_field or rf. The default is only to
return the code of the search result, but by setting those parameters
you can return whichever columns you wish.
.PP
[PREFIX-pos N] outputs the data from the \fIN\fRth column as returned
(starting with zero). [PREFIX-param] lets you access the data by
column name instead of by number.
.PP
In a [query ...] \s-1ITL\s0 tag you can select multiple return fields with
something like:
.PP
.Vb 3
\& [query prefix=prefix sql="select foo, bar from baz where foo='buz'"]
\& [prefix-code] [prefix-param foo] [prefix-param bar]
\& [/query]
.Ve
In this case, [prefix-code] and [prefix-param foo] are synonyms,
as foo is the first returned parameter and becomes the code for
this row. Another synonym is [prefix-pos 0]. [prefix-pos 1] is the
same as [prefix-param bar]. The following code will produce
exactly the same output as the above:
.PP
.Vb 3
\& [query prefix=prefix sql="select foo, bar from baz where foo='buz'"]
\& [prefix-pos 0] [prefix-pos 0] [prefix-pos 1]
\& [/query]
.Ve
Note that if you use the [PREFIX-pos] tag, you may have to review your
column numbers whenever you modify the columns you select. For this
reason, queries that make use of the [PREFIX-param] tag may be
easier to maintain and will be less prone to future surprises.
.Sh "PREFIX-price"
.IX Subsection "PREFIX-price"
.Vb 1
\& [PREFIX-price]
.Ve
The price of the product identified by the current code, formatted for
currency. If Interchange's pricing routines cannot determine the price
(i.e. it is not a valid product or on-the-fly item) then zero is
returned. If the list is a hash list, the price will be modified by
its quantity or other applicable attributes (like size in the
demo).
.Sh "PREFIX-quantity"
.IX Subsection "PREFIX-quantity"
.Vb 1
\& [PREFIX-quantity]
.Ve
The value of the quantity attribute in a hash list. Most commonly
used to display the quantity of an item in a shopping cart
[item-list].
.Sh "PREFIX-subtotal"
.IX Subsection "PREFIX-subtotal"
.Vb 1
\& [PREFIX-subtotal]
.Ve
The [PREFIX-quantity] times the [PREFIX-price]. This does take
discounts into account.
.Sh "if-PREFIX-data"
.IX Subsection "if-PREFIX-data"
.Vb 1
\& [if-PREFIX-data table field] IF text [else] ELSE text [/else] [/if-PREFIX-data]
.Ve
Examines the data field, i.e. [PREFIX-data table field], and if it is
non-blank and non-zero then the \s-1IF\s0 text will be returned. If it is
false, i.e. blank or zero, the \s-1ELSE\s0 text will be returned to the
page.
.PP
This is much more efficient than the otherwise equivalent [if
type=data term=table::field::[PREFIX-code]].
.PP
You cannot place a condition; i.e. [if-PREFIX-data table field eq
\&'something']. Use [if type=data ...] for that.
.PP
Careful, a space is not a false value!
.Sh "if-PREFIX-field"
.IX Subsection "if-PREFIX-field"
.Vb 1
\& [if-PREFIX-field field] IF text [else] ELSE text [/else] [/if-PREFIX-field]
.Ve
Same as [if-PREFIX-data ...] except uses the same data rules as
[PREFIX-field].
.Sh "PREFIX-modifier-name"
.IX Subsection "PREFIX-modifier-name"
.Vb 1
\& [PREFIX-modifier-name attribute]
.Ve
Outputs a variable name which will set an appropriate variable name
for setting the attribute in a form (usually a shopping cart). Outputs
for successive items in the list:
.PP
.Vb 3
\& 1. attribute0
\& 2. attribute1
\& 3. attribute2
.Ve
etc.
.PP
[PREFIX-modifier-name quantity] would be the same as
[PREFIX-quantity-name].
.Sh "PREFIX-quantity-name"
.IX Subsection "PREFIX-quantity-name"
.Vb 1
\& [item-quantity-name]
.Ve
Outputs for successive items in the list:
.PP
.Vb 3
\& 1. quantity0
\& 2. quantity1
\& 3. quantity2
.Ve
etc.
.PP
[PREFIX-modifier-name quantity] would be the same as
[PREFIX-quantity-name].
.SH "Tags"
.IX Header "Tags"
Each \s-1ITL\s0 tag is show below. Calling information is defined for the
main tag, sub-tags are described in \fILooping tags and Sub-tags\fR.
.Sh "accessories"
.IX Subsection "accessories"
A Swiss-army-knife widget builder, this provides access to
Interchange's product option attributes (e.g., to choose or access
product options such as a shirt's size or color).
.PP
Can build selection objects (radio, check, select boxes, etc), forms
or hyperlinks, or can simply return a value.
.PP
Or more \- see also \fILooping tags and Sub-tags\fR.
.PP
Summary
.PP
.Vb 3
\& [accessories code arg]
\& [accessories code=os28044 arg="size, radio, ... " other_named_attributes] deprecated
\& [accessories code=os28044 attribute=size type=radio ... other_named_attributes]
.Ve
.Vb 3
\& Parameters Description Default
\& code Value of the master key in the product (or specified other) tablenone
\& arg Positionally interpreted comma-delimited list of values for the following attributes:"attribute, type, column, table, name, outboard, passed"none
.Ve
.Vb 35
\& Attributes Default
\& attribute none
\& typeOne of select, value, text, textarea, hidden, password, combo, move_combo, reverse_combo, show, options, labels, checkbox, radio, linksselect
\& column attribute
\& table products
\& name mv_order_attribute
\& outboard none
\& passed none
\& key (alias for code) none
\& row (alias for code) none
\& base (alias for table) products
\& database (alias for table) products
\& db (alias for table) products
\& col (alias for column attribute
\& field (alias for column attribute
\& delimiter comma (',')
\& prepend none
\& append none
\& extra none
\& js none
\& rows varies with type; often 4
\& cols varies with type; often 40
\& width none
\& default none
\& price none
\& price_data none
\& contains (type=radio or check) none
\& joiner (type=links) none
\& href (type=links) none
\& template (type=links) none
\& form (type=links) mv_action=return
\& empty (type=links) none
\& secure (type=links) none
\& new none
\& interpolate (reparse) No
.Ve
.Vb 4
\& Other_Characteristics
\& Invalidates cache No
\& Container tag No
\& Has Subtags No
.Ve
\&\fBTag expansion example:\fR
.PP
.Vb 4
\& [accessories os28044 size]
\&---
\&
.Ve
\&\fBASP-like Perl call:\fR
.PP
.Vb 3
\& $Tag->accessories( { code => '[[EXAMPLE_SKU]]',
\& arg => 'color, radio'
\& table => 'special_products', } );
.Ve
or similarly with positional parameters,
.PP
.Vb 1
\& $Tag->accessories($code, $arg, $attribute_hash_reference);
.Ve
See Also
.PP
\&\fILooping tags and Sub-tags\fR.
.PP
Description
.PP
This is the swiss-army-knife widget builder for providing access to
Interchange's product option attributes (e.g., to choose or access
product options such as a shirt's size or color).
.PP
Interchange allows you to choose item attribute values for each
ordered item \- you can attach a size, color, or other modifier to a
line item in the shopping cart. You can also resubmit previous
attribute values via hidden fields on a form.
.PP
The catalog.cfg file directive \fIUseModifier\fR is used to set the
name of the modifier or modifiers. For example
.PP
.Vb 1
\& UseModifier size color
.Ve
will attach both a size and color attribute to each item code that is
ordered.
.PP
\&\fBImportant Note \*(-- \fRYou may not use the following names for
attributes:
.PP
item group quantity code mv_ib mv_mi mv_si
.PP
You can also set modifier names with the mv_UseModifier scratch
variable \- [setEmv_UseModifier] size color [/set] has the
same effect as above. This allows multiple options to be set for
products. Whichever one is in effect at order time will be used. Be
careful; you cannot set it more than once on the same page. Setting
the mv_separate_items or global directive \fISeparateItems\fR places
each ordered item on a separate line, simplifying attribute handling.
The scratch setting for mv_separate_items has the same effect.
.PP
The modifier value is accessed in the [item-list] loop with the
[item-param attribute] tag, and form input fields are placed
with the [modifier-name attribute] tag. This is similar to the
way that quantity is handled.
.PP
\&\fBNote: \fRYou must be sure that no fields in your forms have digits
appended to their names if the variable is the same name as the
attribute name you select, as the [PREFIX-modifier-name size]
variables will be placed in the user session as the form variables
size0, size1, size2, etc.
.PP
Interchange will automatically generate the select boxes when the
[accessories code=\*(L"os28044\*(R" attribute=\*(L"size\*(R"] or
[item-accessories size] tags are called. They have the syntax:
.PP
.Vb 1
\& [item-accessories attribute, type, column, table, name, outboard, passed]
.Ve
.Vb 8
\& [accessories code=sku
\& attribute=modifier
\& type=select
\& column=db_table_column_name
\& table=db_table
\& name=varname
\& outboard=key
\& passed="value=label, value2*, value3=label 3"]
.Ve
.Vb 4
\& [accessories js=| onChange="set_description(simple_options, variant)"; |
\& type=select
\& name="[item-param o_group]"
\& passed="=--choose--,[item-param o_value]"]
.Ve
\&\fBNotes: \fR
.Ip "1." 4
The 'attribute' attribute is required.
.Ip "2." 4
See the type attribute for a list of types.
.Ip "3." 4
The trailing '*' in value2 will mark it as the default ('\s-1SELECTED\s0')
value in the select widget (see below).
.PP
When called with an attribute, the database is consulted and looks for
a comma-separated list of item attribute options. They take the form:
.PP
.Vb 1
\& name_a=Label Text1, default_name=Default Label Text*, name_b, etc.
.Ve
The label text is optional \- if none is given, the \fBname\fR will be
used (as in 'name_b' above).
.PP
If an asterisk is the last character of the label text, the item is
the default selection. If no default is specified, the first will be
the default. An example:
.PP
.Vb 1
\& [item-accessories color]
.Ve
This will search the product database for a field named \*(L"color\*(R". If an
entry \*(L"beige=Almond, gold=Harvest Gold, White*, green=Avocado\*(R" is
found, a select box like this will be built:
.PP
.Vb 6
\&
.Ve
In combination with the mv_order_item and mv_order_quantity
session variables, you can use this to allow a customer to enter an
item attribute during an order.
.PP
If used in an item list, and the user has changed the value, the
generated select box will automatically retain the current value the
user has selected.
.PP
The value can then be displayed with [item-modifier color] on the
order report, order receipt, or any other page containing an
[item-list].
.PP
Emulating with a loop
.PP
You can also build widgets directly, without using the accessories
tag. You may have to do so if you need more control of the content
than the tag offers. Below is a fragment from a shopping basket
display form which shows a selectable size with \*(L"sticky\*(R" setting and a
price that changes based upon the modifier setting. (Note that this
example would normally be contained within the
[item-list][/item-list] pair.)
.PP
.Vb 5
\&
.Ve
The output of the above would be similar to the output of
[item-accessories size, select] if the product database field size
contained the value S, M, L, \s-1XL\s0. The difference is that the options
in the loop emulation show the adjusted price in addition to the size
within each option value.
.PP
\&\fIHash Lists\fR \- Technical Note
.PP
As a technical note, some of the features of this tag work differently
depending upon whether it was called with an '$item' hash reference,
for example, as [item-accessories] within an [item-list].
.PP
In this context, the tag will have access to ancillary data from the
item (including, perhaps, a user's chosen item attribute value). For
example, if building a \s-1TEXTAREA\s0 widget within an [item-list], the
widget will show the chosen item attribute value. On the other hand,
within an array list such as a [search-list] in a
[search-region], the widget would be empty.
.PP
If you really know what you're doing, you can pass it the item hash
reference within a [perl] tag like this:
.PP
.Vb 4
\& $Tag->accessories( $code,
\& undef, # 'arg' parameter value
\& $named_attribute_hashref,
\& $item_hashref );
.Ve
See also Looping tags and Sub-tags for information about
hash-context and array-context in looping tags.
.PP
\&\fIcode\fR
.PP
This is the master key of the specified table (commonly sku in a
product table). If no table is specified, the tag uses the products
table by default.
.PP
You should not specify a code when looping on [item_accessories]
because it internally sets 'code' to the key for the current item
in the loop.
.PP
\&\fIarg\fR
.PP
\&\fBDeprecated after Interchange 4.6\fR
.PP
This allows you to pass values for some of the more commonly used
attributes in the manner of the [item-accessories] tag, as a
comma-delimited positional list:
.PP
.Vb 1
\& arg="attribute, type, column, table, name, outboard, passed"
.Ve
Whitespace within the list is optional.
.PP
If you leave out one or more of the above attributes, be sure to keep
the \fIcomma\fR\|(s) if you are setting anything after it in the list:
.PP
.Vb 1
\& arg="attribute, type, , table"
.Ve
The above examples show the attribute names for clarity; you would
actually use the values. Hence, the previous example might actually be
something like the following:
.PP
.Vb 1
\& arg="color, radio, , products"
.Ve
Although you must use such a comma-delimited list to pass attributes
to the [item-accessories] tag, please use named attributes instead
for the [accessories] tag. The 'arg' attribute is deprecated.
.PP
For detail about a specific attribute, please see its subheading
below.
.PP
\&\fIattribute\fR
.PP
Despite the name, this has nothing to do with tag attributes. You can
set attributes for \fIitems\fR in a database table (typically the
products table) with the UseModifier configuration directive.
Typical are size or color.
.PP
This selects the item attribute the tag will work with.
.PP
\&\fItype\fR
.PP
This determines the action to be taken. One of:
.PP
.Vb 25
\& Action Description
\& select Builds a dropdown