Summary: Create personal or business Contacts pages and lists with Fox
Version: 2017-05-20
Prerequisites: PmWiki 2.2.56+, Fox, FoxEdit, FoxDelete (optional)
Status: stable
Maintainer: HansB
Categories: PIM CMS Fox PHP55
Download: Fox Downloads (external link)
Discussion: FoxContacts-Talk


An application using Fox to create and maintain pages in a Contacts group, which store contact information in form of PTVs (Page Text Variables).


Copy the page files from the zip archive into your wiki.d/ folder, or wiki.d/Contacts/ subfolder, and set in config.php Fox page permissions to $FoxPagePermissions['Contacts.*'] = 'all'; Install Fox, FoxEdit and FoxDelete if you have not done already.

This will create a group named Contacts, with the following pages:

  • Contacts.Contacts - index page
  • Contacts.NewContact - form to add a new contact and edit existing contacts
  • Contacts.ContactTemplates - all fox templates for the forms
  • Contacts.GroupHeader - with (:include ...:) directive for display of Contact PTV data

New contacts are created as new pages in the group, and listed on the index page.

Optional add a pagelist for the sidebar or rightbar to list all contacts:

(:pagelist group={*$Group} list=normal fmt=#title name=-Contact* :)

With custom display templates one could display for instance telephone numbers or email address next to the name. Example, using simple table markup:

(:pagelist group={$Group} list=normal fmt=#customlist name=-*Contact*:)

(:if false:)
(:template first:)
||!Name ||!Phone ||!Email ||
(:template each:)
||[[{=$FullName}|+]] ||{{=$FullName}$:telephone} ||{{=$FullName}$:email} || 

Or other index pages could be added with special listings of selected contact details.

NewContact form

(:if equal {$EditTarget} '':)
(:fox contactform put=top target="{$$ptv_name1} {$$ptv_name2}" template=ContactTemplates#new redirect=1 :)(:input hidden pagecheck 1:)
(:else:)(:fox contactform ptvtarget={$EditTarget} ptvclear=1:)
(:input defaults source={$EditSource} :)
|| '''First Name:''' ||(:input text name="$:name1" size=60:) ||
|| '''Surname:'''||(:input text name=$:name2 size=60:) ||
|| '''Telephone:'''||(:input text name=$:telephone size=60:) ||
|| '''Mobile:'''||(:input text name=$:mobile size=60:) ||
|| '''Email:'''||(:input text name=$:email size=60:) ||
|| '''House/Flat:'''||(:input text name=$:address1 size=60:) ||
|| '''Street:'''||(:input text name=$:address2 size=60:) ||
|| '''Town:'''||(:input text name=$:town size=60:) ||
|| '''Postcode:'''||(:input text name=$:postcode size=60:) ||
|| '''Country:'''||(:input text name=$:country size=60:) ||
|| '''Note:'''||(:input textarea name=$:note cols=60 rows=6:) ||
|| '''Author:'''||(:input text author {$Author} size=60:) ||
|| ||(:input submit post Save:)||
(:foxend contactform:)


!!!#display for contact display 
%define=noteheader apply=block text-align=right bgcolor=#f0f0f0 border="1px solid #ccc"%
(:title {$:name1} {$:name2}:)
[-created {(ftime "%d %b %Y - %H:%M" @{$:date})}-] (:if auth edit:) &nbsp; {[foxedit form=NewContact]}  &nbsp; {[foxdelpage redirect=Contacts.Contacts]}(:if:)
|| ''First&nbsp;Name:''||{$:name1} ||
|| ''Surname:''||{$:name2} ||
|| || ||
|| ''Telephone:''||{$:telephone} ||
|| ''Mobile:''||{$:mobile} ||
|| ''Email:''||{$:email} ||
|| '''''Address'''''&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| ||
|| ''House:''||{$:address1} || 
|| ''Street:''||{$:address2} ||
|| ''Town:''||{$:town} ||
|| ''Postcode:''||{$:postcode} ||
|| ''Country:''||{$:country} ||
||'''''Note:''''' || ||
(:if !equal {$:note} '':)

!!!#new for new contact pages
This is used by form on NewContact page
(:author: {$$author}:)
(:date: {$$(timestamp)}:)
(:name1: {$$name1}:)
(:name2: {$$name2}:)
(:telephone: {$$telephone}:)
(:mobile: {$$mobile}:)
(:email: {$$email}:)
(:address1: {$$address1}:)
(:address2: {$$address2}:)
(:town: {$$town}:)
(:postcode: {$$postcode}:)
(:country: {$$country}:)
(:note: {$$note}:)
(:foxprepend noteform:)
(:include ContactTemplates#noteform:)

!!!#noteform for inclusion

(:fox noteform target={*$FullName} template=ContactTemplates#addnote:)
|| ||''Write new note:'' ||
|| ''Subject:''||(:input text subject size=40:) ||
|| ''Text:''||(:input textarea text cols=30 rows=3:) ||
|| ||(:input submit post 'Add Note':) ||
(:foxend noteform:)

!!!#addnote for adding new notes or comments with noteform
(:div class='frame rfloat':)
[-created {$$(ftime "%d %b %Y - %H:%M")}-] (:if auth edit:){[foxdelrange ]}(:ifend:)
(:div class=frame:)


The NewContact form acts in two ways:

  1. it is used to add a new contact page, using a template.
  2. it is used to edit an existing contact, called by a FoxEdit link, by updating the PTVs of the page.

These two very different functions are combined in one form using a conditional (:if ...:) directive, which checks if the form is creating a new page or is called via foxedit link.

The fox template '#new' on the ContactTemplates page is used to add PTVs. If we wanted only PTVs added, we would not need a template, but just need to set the names of PTVs in a list with commas separating each name to a parameter ptvfields=. Those PTVs could be hidden (default) or in some other visible form, using parameter ptvfmt=text or deflist, or section.

The GroupHeader contains a (:include ContactTemplates#display basepage={*$FullName} :) directive. It provides a way to display the 'data' of the PTVs in the page. Basically it displays (includes) section #display from page ContactTemplates, and uses the values of the PTVs on the specific Contacts page. This has the advantage that we can edit and change the display on all contact pages by editing a single template section, the data and the display of it are separated.

The ContactTemplates#display template section contains a foxedit and foxdelpage link markup, which are only shown to an authorised admin person. Also on the index page each list item has a 'X' link next to it, for convenient page deletion, shown only to an admin person.

Finally in this very brief explanation we can see that each Contacts page has also a Comment form at the bottom, for easy adding multiple comments. This is just a basic Fox comment form, and an add-on to the functionality, which could be stripped.

Release Notes

  • 2017-05-20: Updated NewContacts form and ContactTemplates to work with latest fox.php (version 2017-05-20 or younger). Removed (:title ... :) from being added to new contact page, and allow updating the name fields.
  • 2015-01-08: Simplified display template, by using basepage= parameter in the (:include ContactTemplates#display .... :) directive in the GroupHeader. Added page delete links to index list for admins. This version needs updated FoxDelete script (version 2014-01-08 or later).
  • 2010-03-17: Fixed bug which did prevent editing names with spaces
  • 2010-03-10: fixed a number of bugs, improved templates.
  • 2008-03-29: simplified to use single form for adding and editing pages. For use with latest versions of Fox and FoxEdit
  • 2007-11-23: initial release

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".


See Discussion at FoxContacts-Talk

See Also


User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.