Hello, below is some code I have in a mod_perl handler that checks to
see if an uploaded image is less than 300 pixels tall or wide.
Everything seems to be working except the fact that the template is not
returning with the proper values processed.  Below is the code and the
err_log output when I output an image that is too wide.


[snip] 
my $upload = $r->upload;
my $type        = $upload->type;
my $fh          = $upload->fh;
my $username    = $r->param('username');


my ($x, $y) = imgsize($fh);
print STDERR Dumper($x);
print STDERR Dumper($y);

unless ($x < 300) {
print STDERR "the greater than works\n";
     # This checks to make sure the image isnt more than 300 x 300
     my %vars = {TOO_WIDE => 1};
     my $config = {
                INCLUDE_PATH => '/moc/html/templates',
                POST_CHOMP => 1,
                EVAL_PERL => 1,
     };

     my $template = Template->new($config) || die "New Template Failed:
$!\n";

        #the process method prints the template out to the browser via
$r
        $template->process('pic_upload.tt2', \%vars, $r) || do {
          $r->log_reason($template->error());
          return SERVER_ERROR;
        };
        return OK;

} # end of X/Y coordinate if

[snip]

The err_log output:

$VAR1 = 310;
$VAR1 = 72;
the greater than works

[end of err_log]

The problem is the template pic_upload.tt2 has this in it:

[% IF TOO_WIDE %]
<font color=red>Your File was too big.  Make it under 30K</font><p>
[% END %]

But that isn't showing up.  I do the almost identical thing immediately
after this if clauses to check if the file's type is a jpeg.  That
works, so I don't understand what I pasted in wrong, or forgot to paste
in.

Mike



Mike Melillo
Stab and Kill Records
www.stabandkill.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Andy Wardley
Sent: Tuesday, May 21, 2002 6:36 AM
To: Viljo Marrandi
Cc: [EMAIL PROTECTED]
Subject: Re: [Templates] Displaying SQL data as table

On Tue, May 21, 2002 at 11:53:52AM +0300, Viljo Marrandi wrote:
> Let's say my SQL query outputs following data to me:
[...]
> And with TT I'd like to make a HTML table from this
> that looks like this:
[...]

Have a look at Template::Plugin::Table.  You pass it a list
of data, or an iterator returned by the DBI plugin, and tell it
that you want the data in rows of 3 columns.  Then you simply 
walk over the rows and items in the rows.

   [% USE DBI(dsn,user,pass);
      results = DBI.query('SELECT blah FROM blah');
      USE table(results, cols=3);
      FOREACH row = table.rows;
        FOREACH item = row;
          item.whatever;
        END;
      END;
    %]

A


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates



Reply via email to