[pmwiki-users] PMWiki and Fast Data recipe

The Editor editor at fast.st
Tue Oct 3 08:22:23 CDT 2006


On 10/3/06, Scott Hanselman <scott at skhanselman.com> wrote:
> Hi,
>
> I've been using PMWiki for a short while and really enjoy the wiki way.
> The other day I was trying to make a form that would create a new page
> on the fly. I'm trying to use the Fast Data recipe and have come up with
> the following example, but it doesn't create a new wiki page (however,
> the form displays fine):
>
> (:input form:)
> (:input hidden action data:)
> (:input hidden name="group" value="business":)
>
> Business Name: (:input text "name":)
> Address: (:input text "address":)
> Website: (:input text "website":)
> Email: (:input text "email":)
> Phone Number: (:input text "phone":)
> Fax Number: (:text "fax":)
> Description: (:textarea name="description" cols='60'
> rows='15':)(:textareaend:)
> (:input submit value="Add New Company":)
>
> (:input hidden makepage Group.Name|group,name:)
> (:input end:)
>
> I suspect the problem lies in the (:input hidden makepage
> Group.Name|group,name:) line. The documentation states:
>
> makepage*       Group.Name|(opt)Field1,Field2
>
> I'm not sure what I'm missing or doing wrong. Any suggestions?
>
> Much appreciated,
>
> Scott

Hi Scott,

I'm in the process of reworking the page creation process so it will
be a bit simplier, but I see a few problems right off.

1), I would probably not use the makepage option, but rather just save
the data.  You will want to save the data in a page based on some
input field, in your case probably the business name.

To do this, add the following lines to the form:

(:input hidden datapage "Business.$":)
(:input hidden replace "datapage|name|$":)
(:input hidden savedata "name,address,website...":)

The second line replaces the $ with the value of field name, and then
uses that for the page to store your data.  Make sure your business
names are appropriate PmWiki page names.
Or create a field for pagename and use that instead of name.

To view the datapage, go to Data-Business.SomeCompany. (Or whatever
companyname you entered)

2) Second, you will need to have a way to display the data, probably
in your business group, in a page footer (Business.GroupFooter).  You
can be much more fancy, but something like this will work:

(:data:)
Name: {$name}\\
Address: {$address}\\
Website: ($website}\\
...

Then when you link to Business.SomeCompany, it will retrieve the data
and display it however you wish.  You will probably want to change
your config to hide the question marks and display the page without
going to the edit mode.  I use the following lines

$LinkPageCreateFmt = "<a class='wikilink' rel='nofollow'
href='{\$PageUrl}'>\$LinkText</a>";
$PageRedirectFmt = '';

Third, note Fax Number: (:text "fax":) is missing the "input".

Fourth, if you do want to use makepage, remember it is case sensitive,
so Group is not group.  Also, you are supposed to put the actual group
and name in there.  That is, Business.SomeCompany not Group.Name.
Which means you will want want to do the replace line again to insert
those variables.  ie. something like the savedata snippet above.

To be honest though, I've been reworking on the page template feature
and I don't think it is working properly in the current version for
makepage.  It will be more functional and work better the next release
in a few days. If you can wait, that might be an option. But using
data fields, makes it easy to update information using an update form.

For an example of this, see the demo site.  Specifically the register
code, and the profiles code (which allows updating).  The only
difference is you will want to put these in group Business (not
profiles).  And edit them to your preference.

http://localhost/fastwiki/data/index.php?n=Snippets.Register
http://localhost/fastwiki/data/index.php?n=Snippets.Profiles

Maybe I'll put a simple rolodex snippet up.  Or if you get yours
working, why not add it to the demo site yourself?

Cheers,
Caveman




More information about the pmwiki-users mailing list