[pmwiki-users] WikiSh Shopping Cart recipe

Peter & Melodye Bowers pbowers at pobox.com
Wed Apr 16 09:37:56 CDT 2008

> Peter & Melodye Bowers wrote:
> > Here's a very rough proof-of-concept idea using WikiSh
> 1) The generate form button, which would be the link to the 
> order page 
> in a real shop, does not redirect to Shop.Form. How do you 
> add that? I 

{(wikish_form QUICKFORM PROCESS)} will almost never be called at the same
time as {(wikish_form REDIRECT)} -- the one is setting up a form while the
other is saying to go to a different page.  I'll go in and take a look at my
documentation to make sure I've been clear in how it's supposed to be used.
The one with the REDIRECT option is meant to be called separately from the
form setup stuff, in the code for validating or processing a form:

In the Shop.Code#GenerateForm code (I've inserted the very last line) it
will look like this:

echo "${openparen}:if false:${closeparen}\n{${openparen}wikish source
wikish_form REDIRECT target=Shop.Form     # I INSERTED THIS LINE TO DO THE

Basically "wikish_form REDIRECT" does an immediate redirection, so you
usually will surround it in control structures (if/then, etc.) so that it
will only be executed when you really want to do a redirect right then.  If
it is at the top of the form (with the QUICKFORM and PROCESS) then nothing
on your page will ever be done because the first thing the page will do is
redirect to another page.  (This would be a nice addition to PowerTools,
Hans?  Just a simple {(redirect MyGroup.MyPage)} or maybe with some of those
other options that are in the (:redirect ...:) markup?  My preference would
be a silent, simple redirect by default (just a straight call to
Redirect(PSS($target[0]))), but you know this stuff better than me...)

(QUICKFORM just generates the standard (:input ...:) things you will usually
want when making a form and PROCESS looks for $_POST or $_GET settings and
puts them in variables for use.)

In terms of the specific problem, I was not assuming that the form would be
regenerated each time.  I was assuming that the administrator would generate
the form once and then there would be a simple link to the page.  That's why
I didn't put a redirect attached to that button.  But I can see that most of
the time you would want the redirect there.

> 2) The Shop.Order page is not created at all. Shop.Form was, 
> so it's not 
> a write permissions issue. The same redirect question as above too 
> because Shop.Form would need to redirect to Shop.Order.

So you went to Shop.Form, put in a quantity in one or more fields, pressed
"Check Out" and the Shop.Order was not generated?  And no error message?

Strange...  I copied the code into the example page immediately after
successfully testing the snippet successfully in a couple different ways...

Could you send me (offlist) a copy of your Shop.Code page and Shop.Form page
-- I'll see if anything rings a bell...

I've already got the Shop.Form redirecting to Shop.Order when you press
"Check Out", so there shouldn't be any need to change anything there.  (Look
for the "wikish_form target=${orderpage} REDIRECT" in

> - How should permissions be set so that any visitor can create/modify 
> only the order page?
> $WikiShWriteList = array('Shop.Order')?

Yes, that should do it, although your comment below is absolutely correct -
it will need to be visitor specific.  Either we need to be creating the
orders in Shop.Order-0001 style pages or else we need to use sessions as you
mentioned below.

> Btw, the order page would be visitor specific. Don't we need sessions 
> for this? Should it be a session page URL like 
> Shop.Order-3h7ft219IJH5656dddgyg? I don't know how pmwiki 
> handles sessions.

Hmmm...  There's a recipe out there called httpvariables that allows
interaction with SESSION variables - don't remember the exact details and I
don't know if it allows setting of SESSION variables or only reading of the

I could easily create a --session option for the {(set ...)} MX which would
save to a session variable rather than to a PHP variable.  Or, with a little
more work, I could create capability of having all files in a certain group
(i.e., "Session.PageA") be created as virtual pages saved in your session.
Would either of those be of interest?  I would think much better from a
security perspective...

> I downloaded WikiSh a few hours ago, is that the latest? I'm 
> running the 
> latest pmwiki (...beta65).

I released last night so if you've got the 2008-04-15 version then you've
got the latest.  You can check by looking at the source (line 12:
$RecipeInfo['WikiSh']['Version'] = '2008-04-15';) or by running {(echo


More information about the pmwiki-users mailing list