[pmwiki-users] Misc ZAP questions...

marc gmane at auxbuss.com
Sun Oct 29 13:01:10 CST 2006


The Editor said...
> On 10/29/06, Crisses <crisses at kinhost.org> wrote:
> >
> > On Oct 29, 2006, at 9:57 AM, The Editor wrote:
> >
> > I'm answering only what I can....
> >
> > > Still working on ZAP to improve code and functionality and have a few
> > > misc questions.  Kind of unrelated but can't seem to find answers...
> > > I've studied the pmwiki docs, php.net, and tinkered repeatedly but
> > > answers elude me.
> > >
> > > 1) Is there any way to insert php into a page.  In drupal, admins (or
> > > whoever you defined to) could put <? misc code ?> and it would execute
> > > that code.  I'm thinking this might be the key to a shopping cart
> > > recipe I'll be tackling soon.
> >
> > Well -- aside from being VERY dangerous, why not use custom markup?
> > (:php:)code here
> > (:phpend:)
> > Then you can ONLY enable this feature for specific pages.
> >
> > To use the code, you'd have to eval($variable); the code.
> >
> > I caution you VERY STRONGLY from requiring something like this for
> > shopping carts.  Nothing I've been thinking requires custom code IN
> > the wiki.
> 
> Well, I just needed a little script to calculate the price from the
> saved cart data.  Guess it would be just as easy to do a little
> javscript snippet and embed that. Actually that's what I'm doing now.
> I'd just have to trim it down and rewrite it a bit.  Probably easier
> than php.  And safer.

Usually you recalc the cart total when you add an item/delete - at 
least, that's what I do. It's useful to do the round trip to the server, 
because you can keep the total in a session variable for constant 
display in the sidebar (or wherever)

  (:if ! equal {$CartItemCount} "0" :)
  %sidehead% [[Cart]]
  * Items in cart: {$CartQuantity}
  * Total: £{$CartTotal}
  %blue% [[Site/Checkout]]
  (:ifend:)

I think I mentioned before that I keep the cart object in a session 
variable

  session_start();
  $cart =& $_SESSION['cart'];
  if(!is_object($cart)) $cart = new wfCart();

so all the session variable handling is done automatically. Gotta love 
objects.

-- 
Best,
Marc





More information about the pmwiki-users mailing list