
02 Jun fhaperson – Home-grown Joomla Plug-In
As an exercise I decided to try and write a Joomla plugin that could be called from and Joomla article and would replace the plugin call with information about the individual from the FHA (online) Directory.
To use, insert the following “code” into any Joomla article:
{fhaperson person-id template}
where:
- {fhaperson and } are exactly as written
- person-id is the index in the database table tblNamesX for the person whose information you want to appear, separated from “fhaperson” by one or more spaces, and
- template, if used, is any string of alphanumeric characters which will replace the code in the published article on the website. Template is separated from person-id by one or more spaces. The default template is “!inl !phl”, which can be changed on the Options tab of the plugin’s Joomla admin page. (Login to Admin, go to Extensions->Plugins.)
The following tokens, if found in the template, will be replaced by information from the FHA directory database:
Token | Directory Datum | Token | Directory Datum |
!in | Informal name | !inl | Informal name, linked to email |
!fn | Formal name | !fnl | Formal name, linked to email |
!ph | Phone number | !phl | Phone no. linked to tel: (for mobile devices) |
!em | Email address | !eml | Email address, linked to email |
!st | Street address | !stl | Street address, linked to Google maps |
Note: Contact information returned will be that registered as an FHA “context”, which is determined by a Joomla “Tag” attached to the article where the plugin is inserted. Currently the only defined contexts are Contexts/FHA and Context/Service Group
The template will be returned with the token(s) replaced by their directory values.
Example
The following input:
Unlinked Examples
{fhaperson 2517 !in, !st &rlbrace; provides an informal name, and a street address.
{fhaperson 749 !fn (!st), !ph &rlbrace; shows a name, street address, and phone number.
This article’s id=5964.
{fhaperson 904 !fn&rlbrace; should be the name
Linked Examples
{fhaperson 2517 !inl, !stl &rlbrace; provides an informal name linked to an email, and a street address linked to google maps.
{fhaperson 749 !fnl (!stl), !phl &rlbrace; shows a name (email-linked), street address linked to google maps, and phone number linked to make a phone call on a device that is capable of that.
{fhaperson 904 !fnl&rlbrace; should be the name linked to a mailto: email.
are the source for this page.
Finding the person-id
[ed. note: I tried to think of an alphabetic string to use instead of a database index, but there are a few duplicates, even if one uses the full name of the individual, which could be quite long. So the database index won out.]
To find a person’s person-id, look him or her up in the online directory. Then open the browser’s debugging panel – F12 for Chrome or Firefox – then right-click in the blank space close to the upper-right corner and click Inspect (Chrome) or Inspect Element (FF). You should see something like this in the debug window:
The numbers, in this case 568, 1858, etc., are the person-ids of everyone in the residence, in the order in which they appear on the left side of the ddirectory entry where names are listed.