Index  Up  <<  >>  


One-click Multiple Variables

MiniVend can set multiple variables with a single button or form control. You first define the variable set (or profile, as in search and order profiles) inside a scratch variable:

  [set Search by Category]
  mv_search_field=category
  mv_search_file=categories
  mv_todo=search
  [/set]

The special variable mv_click sets variables just as if they were put in on the form. It is controlled by a single button, as in:

    <INPUT TYPE=submit NAME=mv_click VALUE="Search by Category">

When the user clicks the submit button, all three variables will take on the values defined in the ``Search by Category'' scratch variable. You can set the scratch variable on the same form as the button is on -- in fact that is recommended for clarity.

The mv_click variable will not be carried from form to form, it must be set on the form being submitted.

The special variable mv_check sets variables for the form actions checkout, control, refresh, return, search, and submit. This function operates after the values are set from the form, including the ones set by mv_click, and can be used to condition input to search routines or orders.

The variable sets can contain and be generated by most MiniVend tags -- the profile is interpolated for MiniVend tags before being used. This may not operate how you would expect -- for instance, if you set:

    [set check]
    [cgi name=mv_todo set=bar hide=1]
    mv_todo=search
    [if cgi mv_todo eq 'search']
    do something
    [/if]
    [/set]

The if condition is guaranteed to be false, because the tag interpretation takes place before the evaluation of the variable setting.

Any setting of variables already containing a value will overwrite the variable, so to build sets of fields (as in mv_search_field and mv_return_fields) you must use comma separation if that is supported for the field.

It is very convenient to use mv_click as a trigger for embedded Perl:

    <FORM ...
    <INPUT TYPE=hidden NAME=mv_check VALUE="Invalid Input">
    ...
    </FORM>

    [set Invalid Input]
    [perl]
    my $type        = $CGI->{mv_searchtype};
    my $spell_check = $CGI->{mv_spelling_errors};
    my $out = '';
    if($spell_check and $type eq 'text') {
        $CGI->{mv_todo}     = 'return';
        $CGI->{mv_nextpage} = 'special/cannot_spell_check';
    }
    return;
    [/perl]
    [/set]


Index  Up  <<  >>