Hey gang,

I'm doing a website for my mom's puppy pillow company (http:.//www.boyosplace.com), and I'm attempting to use HTML::Template and CGI::Application to accomplish a shopping cart/store app.

What I'm running into is when I try to add the product to the cart, the item parameter isn't being coerced (am i using the correct word in this case?) into the template paramater in the TMPL_LOOP from the query string.

sub retrieve { my $self = shift; use Data::Dumper; my $q = $self->query; my $tmpl = $self->load_tmpl( "showitem.html", loop_context_vars =>1, associate => $q); $tmpl->param( product => $self->dbh->selectall_arrayref(q[SELECT ima +ge, price, description, serial FROM product WHERE id=?], { Slice => { +} }, $q->param('item') )); return $frm->build_page( { title => "Boyo's Place: " . $self->dbh-> +selectrow_array(q[SELECT name FROM product WHERE id=?], { Slice => {} + }, $q->param('item') ), output => $tmpl->output } ), $q->code(Dumper +(\$tmpl)); }
<!--TMPL_LOOP name="product"--> <table width="400" border="1" cellspacing="0" cellpadding="3"> <tr> <td><!--TMPL_VAR name="image"--></td> <td align="right">Price: $<!--TMPL_VAR name="price"--></td> </tr> <tr> <td colspan="2" align="justify"><!--TMPL_VAR name="description"--></td> </tr> <tr> <td colspan="2"><a href="?mode=add_to_cart&amp;item=<!--TMPL_VAR n +ame="item"-->&amp;serialn=<!--TMPL_VAR name="serial"-->">add to cart< +/a></td> </tr> </table> <!--/TMPL_LOOP-->

I've tried using Data::Dumper to sort out the $tmpl hash...but to no avail.

Can someone help me?

meh.

In reply to CGI::Application/HTML::Template problem by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.