Glossary CFC
The inspiration for this cfc came to me whilst reading an article by Michael Dinowitz in the excellent Fusion Authority Quarterly Update called Making Google Pay (Part 1). Michael explained why having a glossary on a Website can be a good thing for your users and search engines. I thought it would be a good idea to write something in Coldfusion that allowed glossary functionality to be employed in web applications. E.G. a CMS.
What is glossary cfc?
Glossary CFC is a Coldfusion component that searches through a string of text looking for words that you have designated as being part of your Website's glossary. As it finds a glossary word it wraps it in a hyperlink pointing to the words definition on the glossary page, before finally returning the full text with all the glossary words found in it hyper-linking to their definition. You can see an example of Glossary CFC running here
Why have a glossary page on your site?
- Help new users by making your site more user friendly. E.G. All industry specific words on your site can link to their own definitions. This can help new user's understand concepts on your Website that they might not be familiar with.
- Google likes internal links on a Website. Having a glossary can be a powerful way to improve Google pagerank.
How does it work?
It takes 3 required attributes.
- glossaryOfWords - The list of words you want in your glossary.
- textToRead - The string of text you want to check for glossary words in.
- templateName - The name of the .cfm template displaying the actual defintions of the glossary words. That each glossary word found will link to.
Suggested Usage
Although its possible to use a static list of words for the value of the glossaryOfWords attribute this value is best stored in a database. In each record there should be aa seperate field. That way the Websites glossary page and value for glossaryOfWords can updated by CMS users as they wish.
Ideally the component should be integrated completely into your CMS so that as each article is input it can be glossarized with the resulting output text stored as the defintive article text.
Running Example
Click here to see Glossary cfc running as used in the code below.
<cfset documentText = "The KDE desktop offers audiokonverter, while GNOME provides audio-convert and audio-convert-mod.
The latter two are separate projects despite their similar names.
audiokonverter provides packages for Debian, Ubuntu, openSUSE,
and generic RPM distributions on its home page, even though the distribution repositories
for Gutsy, Fedora, and the openSUSE Build Service do not offer packages for audiokonverter.
Packages for audio-convert are offered for Gutsy as nautilus-script-audio-convert.
The Fedora repositories contain audio-convert-mod, but it is not packaged for other distributions.
For this article I used the
generic RPM for audiokonverter, installed audio-convert from source, and used audio-convert-mod from the Fedora repository." >
<!---END init documentText with text you want to glossarize --->
<!---Set the words that appear in your glossary --->
<cfset glossaryList = "KDE, GNOME, Fedora, Debian, Ubuntu, openSUSE, RPM, Gutsy, repository">
<!---call cfglossary --->
<cfset franchiseGloss = createObject("component","cfglossary").init(documentText,glossaryList,"glossary.cfm")>
<cfset result = franchiseGloss.glossarize()>
<!---output glossarized text from cfglossary --->
<cfoutput>
#result#
</cfoutput>
Download You can download a zip of cfGlossary here along with docs and example code.
Subversion The latest version can be retrievied from its SVN repository here https://svn2.hosted-projects.com/stewy/myApps/glossary/