Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [courierb] display array value in template: Edit Log

Here is the list of edits for this post
Re: [courierb] display array value in template
HI andy

i got nothing printed o out i wonder if i am doing something wrong? i thing $orderdetail is not passing correctly to the code. i may missing something there. could you remind me of it?


array value of ordertail {name => 'name111',colour => 'red'},{name => 'name222',colour => 'yellow'}
there is a column called ordertail on the table
the sub name called get_values_from_order
sub {
# splits them up into stuff like "{name => 'name222',colour => 'yellow'}"
my @split = split /\Q},{/, $_[0];
my @loop;
foreach (@split) {
s/^{//;
s/}$//;
my $hash;
my @tmp = split /,/, $_; # now lets split them at ',
my @subloop;
foreach my $tmp (@tmp) {
my $hash;
my ($name,$value) = split / => /, $tmp;
$hash->{name} = $name;
$hash->{value} = $value;
$hash->{value} =~ s/^\'//;
$hash->{value} =~ s/\'$//;
push @subloop, $hash;
}
push @loop, { subloop => \@subloop };
}
return { split_loop => \@loop };
}

i called below code on detail page. and it has no error now. but have nothing print out.
<%get_values_from_order($orderdetail)%>
<%if split_loop.length%>
<%loop split_loop%>
<%loop subloop%>
<%name%> = <%value%> <%ifnot last%>, <%endif%>
<%endloop%> <%endloop%> <%endif%>

Last edited by:

courierb: Jul 25, 2009, 8:18 PM

Edit Log: