(Note: I am no longer using Textpattern to run this site but will maintain this page for posterity).
I have ported the Wordpress acronym plugin by Joel Bennett to TXP and you can see it in action on this site and on this page. The existing acronym mods for TXP worked fine, but it appeared that they all required some modifications to the core TXP code. I wanted the acronym feature without the hacks, so I decided to port the WordPress plugin to TXP.
I cannot take much credit for this plugin. Joel, who kindly released his code under the GPL, did all the heavy lifting. All I did was figure out how to pull the TXP content into the plugin and get it back out. I am sure that there is a better way to do what I have done, but it works.
This plugin is intended to replace the <txp:excerpt /> and <txp:body /> tags. The usage is as follows:
<txp:cng_acronym content="value" />
The “value” can be either “excerpt” or “body.” If no “value” is specified, it defaults to “body.”
The plugin will pull the content from the “excerpt” or “body,” depending on what is assigned to the content value, and then parse it through the acronym array. It will then return the entire content with the <acronym></acronym> tags surrounding any found acronyms.
So, in your article form where you might have the following:
<div class="articles"> <txp:excerpt /> <txp:body /> </div>
you would change it to this to use the plugin:
<div class="articles"> <txp:cng_acronym content="excerpt" /> <txp:cng_acronym content="body" /> </div>
The list of acronyms is within the plugin and can be edited to add or delete acronyms. The correct format for the acronym list is as follows:
“ACRONYM” => “Descriptive text goes here”,Note the comma at the end. There must be a comma after each entry in the acronym list except for the last entry, after which there should be no comma.
Thus:
“FAQ” => “Frequently Asked Questions”,would then wrap any found instance of “FAQ” with tags, e.g., “<acronym title="Frequently Asked Questions">FAQ</acronym>”. You can then add a CSS rule for your acronym tags in your stylesheet, like this:
acronym, abbr, span.caps
{
font-size: 1.1em;
letter-spacing: .07em;
border-bottom: 1px dashed #999;
cursor: help;
}
If there are any acronyms that you do not wish to have wrapped in <acronym></acronym> tags, then wrap dollar signs around the acronym, like so:
$$FAQ$$In this case, the dollars signs would be stripped and the acronym would be left alone.
This plugin will also strip out any existing <acronym> tags already in your content, so you may want to make sure the acronyms you have defined manually are added to the acronym array in the plugin.
Finally, in the plugin code you will note that there are different “expressions” that are available if one finds that the plugin is acting wonky. One of these will allow lower-case acronyms to be wrapped in the tags. If you decide to try one of these other expressions, then be sure to comment out the default one by inserting two forward slashes (//) at the start of the line containing the default expression. The original plugin author added some commentary about this which I have left intact. For most folks, however, the defaults will work fine.
Thanks and enjoy!
####Version history
0.2: Released 2005-11-16. Added ability to strip out existing acronym tags from the content to prevent an acronym from being wrapped twice. Download plugin here. Source is available here.
0.1: Released 2005-11-15.
| $Id: txp-acronym-plugin.html,v 1.16 2008/06/06 01:28:05 chess Exp $ |
|