Related Topics: ColdFusion on Ulitzer

CFDJ: Article

Harnessing the Magic of the <gleep> Tag

Harnessing the Magic of the <gleep> Tag

What the bleep is a "gleep" tag? Now I know you've never heard of it, but then neither have any browsers. That's where the magic comes in.

From the dawn of the Internet, it has been a prime directive of all browsers to ignore any tags they do not recognize, and that is what the <gleep> tag depends on. You can have all sorts of "tags" on your HTML pages to use for all sorts of things, and they will never be visible in the browser window. And simple ColdFusion functions allow you to easily do some powerful things.

Case in Point
One of your sites has a page with a certain section that must be periodically updated with new or revised text. Your boss or client wants a clerical person (who is paid far less than the regal hourly rate you make for programming) to be responsible for doing this work. Now, before you scour the Web for some CFX or package that can make this happen without the nontechie screwing it up, please realize that as programmers, we can "invent" a solution rather than buy one. (That's what we do!)

All we need to do is put up a form for someone to enter the new content. Using the code below will simply and efficiently replace the old version of the text with the new text from a form where the user inputs the new text or edits the existing text. All that's needed is that the page being updated has the editable text area bracketed with <gleep> tags. The code immediately below would appear in the form that shows the present content of the editable area for possible revision:

<CFFILE Action = "READ" FILE = "#ExpandPath(‘mypage.htm')#"
VARIABLE = "pagecontent">
<cfset pagecontent = Replacenocase(pagecontent, "<gleep>",
chr(7), "ALL")>
<cfset editablearea = ListGetAt(pagecontent, 2, chr(7)>
<TEXTAREA NAME="editablearea">#editablearea#</TEXTAREA>

This code (in the form action page) writes the new version back to the edited page:

<CFFILE Action = "READ" FILE =
"#ExpandPath(‘mypage.htm')#" VARIABLE = "pagecontent">
<cfset pagecontent = Replacenocase(pagecontent, "<gleep>", chr(7), "ALL")>
<cfset pagecontent = ListSetAt(pagecontent, 2, form.editablearea, chr(7)>
<cfset pagecontent = Replace(pagecontent, chr(7), "<gleep>", "ALL")>
<CFFILE Action = "WRITE" FILE = "#ExpandPath(‘mypage.htm')#" OUTPUT =

Now, by adding only five gleep-related statements, you're all done! Is that not magic?

What's happening is that the replacement of the gleep tags with any convenient character will never appear in the actual page text. (I use chr(7) because in ancient times, chr(7) was what made your computer emit a beep and "beep" rhymes with "gleep".) This creates a CF list with three elements, one before the <gleep>, one between the two <gleep>s, and one after the second <gleep>. You can then conveniently use all the nice CF list functions.

Then, this chr(7) is used as the list-delimiter for a ListSetAt(). We then put the <gleep>s back so they will be there for next time, and so they will be ignored by browsers. This also allows your users to do it again and again until they get it the way they like.

You might also thoughtfully add


to shoot the user over to the page for viewing after the change is made.

Cascading <gleep> Tags
No rocket science here, but if you have a series of things that must be added to or edited seperately, you can just have a series of <gleep>s and replace them as needed with a series like:

<cfset pagecontent = ListSetAt(pagecontent,2,form.newtext,chr(7)>
<cfset pagecontent = ListSetAt(pagecontent,3,form.newtext,chr(7)>
<cfset pagecontent = ListSetAt(pagecontent,4,form.newtext,chr(7)>

and so forth.

You can see an example of this at Of course you need to do a "View Source" to see them.

Note that there is no such thing as a </gleep> tag, as it would make the coding more complicated than we want to bother with – and we certainly want to keep everything simple!

Multiple <gleep> Tags
If the "cascading" form is not powerful enough for you, the "multiple" form can be used. On one site I did, every month the resident astrologer has to create a new horoscope page with a blurb for each of the 12 astrological signs. The strategy is almost the same, with the difference being that there are 12 pairs of <gleep> tags: <gleepAries>, <gleepTaurus>, etc. There's also a "general" blurb for each month.

The code looks like this :

<cfset signs =

<cfloop index="sign" list="#signs#">
<cfset PageContent =
<cfset SignContent = trim(evaluate("form.gleep#sign#"))>
<cfset PageContent = listsetat(PageContent,2,SignContent,chr(7))>
<cfset PageContent =

Now that you understand the principles of <gleep>-ing I'm sure that you clever readers will think of things to do with them that I haven't. Please let me know what you come up with! We can do some powerful things with very simple code. I like that.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.