Textpattern : Textpattern Microformats Plugin [pnh_mf]

Feedback can be offered via this forum thread on the official Textpattern forums.

pnh_mf is a plugin for the popular Textpattern blog software and CMS that adds a simple way to incorporate microformats into your website.

Microformats, if you haven't encountered them, are a collection of defined ways of using the XHTML tags and attributes you have always used in order to model data in a way that can be picked up and interpreted by a variety of tools (like saving vcards for importing them into other applications). And that there is one helluva sentence.

Version History

Version 1.2 - Released 3/18/2007 - Made compatible with Textpattern 1.0.4

Version 1.0 - Released 6/25/2006 - Added support for the hReview microformat and made some minor bug fixies to hCard and elsewhere.

Version 0.8 - Released 1/23/2006 - Includes new admin side 'Useful Tags' helpers and some minor bug fixes.

Version 0.5 - Released 1/15/2006 - Initial Public Release.

Tags included in the current version of this plugin

All of these tags can be used in either templates ('pages'), snippets ('forms') or in article bodies, but cannot be used in comments. Unless otherwise stated, all attributes for each tag have been shown in the example usage.


XFN microformat

This microformat is used to designate a relationship between the owner of a document and the person being linked. See the spec page for valid values for defining such relationships.

Attributes & Content
  • rel
  • href
  • name (content)
<txp:pnh_mf_xfn rel="contact" href="https://placenamehere.com">Chris</txp:pnh_mf_xfn>


<a href="https://placenamehere.com" rel="contact">Chris</a>

This tag also supports the following standard attributes: id, class, title


hCard microformat

This microformat provides a standard way of describing a contact and follows the vcard standard. This is quite a flexible format that can be used to identify everything from an AIM screen name to a person's birthday. The pnh_mf_hcard tag is a bit less flexible but can include all of the attributes shown in the examples.

Attributes & Content
  • name
  • href
  • org
  • orghref
  • photo
  • email
  • worktel
  • hometel
  • celltel
  • workfax
  • address(es) (content)

The pnh_mf_hcard tag can accept one or more addresses via the pnh_mf_adr tag. See below for details of pnh_mf_adr usage.

<txp:pnh_mf_hcard name="John Doe" href="http://john.example.com/" orghref="http://example.com/" org="Example Group, LLC" email="john@example.com" imghref="https://placenamehere.com/temp/butters.gif" worktel="(555) 555-WORK" hometel="(555) 555-HOME" celltel="(555) 555-CELL" workfax="(555) 555-0FAX x123">
<txp:pnh_mf_adr type="home" />
photoJohn Doe
Work: (555) 555-WORK
Home: (555) 555-HOME
Cell: (555) 555-CELL
Fax: (555) 555-0FAX x123
home Address
<div class="vcard"><img src="https://placenamehere.com/temp/butters.gif" alt="photo" class="photo" /><a class="url fn" href="http://john.example.com/">John Doe</a><div><a href="http://example.com/" class="org">Example Group, LLC</a></div><div class="tel"><span class="type">Work</span>: <span class="value">(555) 555-WORK</span></div><div class="tel"><span class="type">Home</span>: <span class="value">(555) 555-HOME</span></div><div class="tel"><span class="type">Cell</span>: <span class="value">(555) 555-CELL</span></div><div class="tel"><span class="type">Fax</span>: <span class="value">(555) 555-0FAX x123</span></div><div><a class="email" href="mailto:john@example.com">john@example.com</a></div>
<div class="adr"><div><span class="type">home</span> Address</div></div>


adr microformat

The adr microformat is used to designate an address and is taken from a subset of the hCard standard.

  • postofficebox
  • streetaddress
  • extendedaddress
  • locality
  • region
  • postalcode
  • country
<txp:pnh_mf_adr streetaddress="9 Happy St." extendedaddress="Apt. 3" locality="Somecity" region="NJ" postalcode="12345-6789" country="U.S.A." />
9 Happy St.
Apt. 3
Somecity, NJ 12345-6789
<div class="adr"><div class="street-address">9 Happy St.</div><div class="extended-address">Apt. 3</div><span class="locality">Somecity</span>, <span class="region">NJ</span> <span class="postal-code">12345-6789</span><div class="country-name">U.S.A.</div></div>

This tag also supports the type attribute for use in conjunction with pnh_mf_hcard.


hCalendar microformat

This is used to define an event that can be extracted and imported into any calendaring application that supports the iCalendar standard.

Attributes & Content
  • summary
  • location
  • href
  • dtstart (machine formatted start)
  • start (human readable start)
  • dtend (machine formatted end)
  • end (human readable end)
  • description (content)

If no values for human readable start and end dates are provided they will be generated based on the entered values of dtstart and dtend.

Please be aware of expectations on hCalendar dates, particularly concerning end time values and its exclusivity.

<txp:pnh_mf_hcalendar summary="SXSW" location="Austin" href="http://2006.sxsw.com/" dtstart="20060310" start="March 10" dtend="20060320" end="19, 2006">
A Description
<div class="vevent"><a class="url" href="http://2006.sxsw.com/"><abbr class="dtstart" title="20060310">March 10</abbr> - <abbr class="dtend" title="20060320">19, 2006</abbr> - <span class="summary">SXSW</span> - <span class="location">Austin</span></a><div class="description">
A Description


hReview microformat

Detailed documentation to come. In the mean time see the microformats.org site and the plugin help inside the Textpattern admin area.


relTag microformat

The reTag microformat offers a standard way of designating a link as a “tag” for the current document.

Attributes & Content
  • href
  • tag (content)

If no href is defined a link to Technorati will be used.

<txp:pnh_mf_tag href="http://del.icio.us/tag/textpattern">textpattern</txp:pnh_mf_tag>

<a href="http://technorati.com/tag/textpattern" rel="tag">textpattern</a>

This tag also supports the following standard attributes: id, class, title


relLicense microformat

The reLicense microformat offers a standard way of designating a link representing a license (CC, GPL, etc.) for the current document.

Attributes & Content
  • href
  • link text (content)
<txp:pnh_mf_license href="http://creativecommons.org/licenses/by-nc-sa/2.0/">by-nc-sa 2.0</txp:pnh_mf_license>

by-nc-sa 2.0

<a href="http://creativecommons.org/licenses/by-nc-sa/2.0/" rel="license">by-nc-sa 2.0</a>

This tag also supports the following standard attributes: id, class, title


geo microformat

this microformat marks up something something.

This microformat is only in the working draft stage and may change in the future.

  • lat
  • long
<txp:pnh_mf_geo lat="0.1" long="0.2" />

0.1 0.2

<span class="geo"><span class="latitude">0.1</span> <span class="longitude">0.2</span></span>

Changes planed for the next version

  • Build up smarter handling for hCalendar dates
  • Put in some screening for hcard name formatting (fn v. n)
  • Continue to review markup chosen and supplied sample styles for flexibility

Other ideas for future versions

  • See about linking the more complex formats to txp forms so that the markup can be easily altered
  • Make all attribute screening more robust and make sure formatting rules are followed
  • Look to include other microformats that are stable and can be implemented sensibly.

Last Updated 03/18/2007