FoxContacts

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

Description

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

Installation

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:

*[[NewContact]]
!!!!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:)
[[#customlist]]
(:template first:)
||
||!Name ||!Phone ||!Email ||
(:template each:)
||[[{=$FullName}|+]] ||{{=$FullName}$:telephone} ||{{=$FullName}$:email} || 
[[#customlistend]]
(:ifend:)

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

Live example: FoxContacts

Notes

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".

Comments

See Discussion at FoxContacts-Talk

See Also

Contributors

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.