MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: Forcing Order of interpolation?



>******    message to minivend-users from Nicholas Albright
><albrnick@bobcat.ent.ohiou.edu>     ******
>
>
>  I was wondering if there was a way of forcing the order of
>interpolation?  Basically, I'm trying to create a fairly dynamic form,
>where the user can enter the number of 'items', and the form will adjust
>to that number of items.  Here is my perl script on that page:
>
>-----Begin Code-----
>[perl interpolate=1]
>my($string);
>
>$string = "";
>$string .= "<FORM ACTION=\"[process-target]\" METHOD=\"POST\">\n";
>$string .= "<INPUT TYPE=HIDDEN NAME=mv_doit VALUE=refresh>\n";
>$string .= "<INPUT TYPE=HIDDEN NAME=mv_todo VALUE=refresh>\n";
>$string .= "<INPUT TYPE=HIDDEN NAME=mv_orderpage VALUE=\"thispage\">\n";
>$string .= "Number: ";
>$string .= "<INPUT TYPE=TEXT NAME=num_items VALUE=[value num_items]>\n";
>
>my($item);
>
>for $item (1..[value num_items]) {
>  $string .= "<INPUT TYPE=TEXT NAME=name_$item ";
>  $string .= "VALUE=\"[value name_$item]\" SIZE=20>\n";
>}
>
>$string .= "</FORM>\n";
>
>return ($string);
>[/perl]
>-----End Code-----
>
>  My problem occurs in the loop.  I need "$item" to be evaluated before
>[value name_$item].
>
>  Any ideas?  Or is this not possible, and I need to find another way?
>(Such as running a separate CGI script)
>
>  Thanks for your time!
>   -Nick
>

If you use [perl interpolate=1] this will interpolate all the minivend tags
in your code prior to evaluation of the perl code. It will not start
interpolation again in a loop construct.

In your particular example I strongly suggest you create the form with
regular minivend tags, perl does not seem necessary here. If you really
want to use perl, you could use a perl sub as a replacement for the loop
that accepts num_items as a parameter, no interpolation would be necessary.

As a more direct solution for your problem, escape the sqaure brackets in
  $string .= "VALUE=\"[value name_$item]\" SIZE=20>\n";
to prevent early interpolation of the value tag.

Frank


--
Frank Miedreich
Max-Planck-Institut fuer psychologische  Forschung
Leopoldstr. 24   80802 Muenchen   +49 89 38602-237




Search for: Match: Format: Sort by: