[ic] Catalog subroutines
Kevin Old
interchange-users@icdevgroup.org
Thu May 1 15:40:00 2003
On Thu, 2003-05-01 at 14:48, Caleb Groom wrote:
> I'm trying to add a catalog subroutine according to the documentation in
> "26.94. Sub". The example there a sort_cart_by_quantity function that
> builds a string and returns it.
>
> For practice I'm taking the foundation catalog and adding the number of
> items in the cart to the upper right hand section of the page. Here's my
> function as listed in catalog.cfg:
>
> Sub <<EOF
> sub show_custom_cart {
> my $out = sprintf("%d item%s", scalar @{$Carts->{main}}, scalar
> @{$Carts->{main}} == 1 ? "" : "s");
> return $out;
> }
> EOF
>
> I call it like so:
>
> Your cart: [perl] return show_custom_cart(); [/perl]
>
> And I receive this error:
>
> [01/May/2003:13:47:42 -0500] fstore /fstore/index.html Safe: Undefined
> subroutine &main::show_custom_cart called at (eval 201) line 1.
> >
> > return show_custom_cart();
> >
>
> Have I missed a step? Will Safe get in the way here? How do I get this to
> work?
Caleb,
Where is the subroutine defined? Global or Catalog?
On the number of items in the cart....why not use the [nitems] tag?
HTH,
Kevin
--
Kevin Old <kold@carolina.rr.com>