Since you are building a CMS from the ground up, why not build in
proper natural page names?

In the page editor of a given page, add a field called "friendly page
name".  The person editing puts in the page name (or provide some sort
of mechanism that suits you).  Upon saving, the name is tested against
whatever format criteria you decide upon (alphanumeric, no spaces
etc.), is dupe-checked against the current page table to ensure the
desired name has not yet been picked for another page and further
checked against a reserved-name list to ensure no one chooses a page
like "application', thereby creating "application.cfm" :-0 ...

Next you have to take care of publishing the page.  You can probably
publish a truly static content page (mypage.html) and save yourself an
enormous amount of server resources.  Or you can do something I call a
"pseudo-static" page, which works like this:

Your cms will have some sort of main page-display template... called
lets say "show.cfm".  show.cfm?ID=123 displays page ID 123,
show.cfm?ID=456 pumps out ID # 456 and so on.  Adapt this page so its
query instead pulls a page name.  If the requested url is

http://mydomain.com/foo.cfm

you can use this

theNameOnly=ListFirst(ListLast(cgi.Script_Name,"/"),".");

to put the value "foo" into the variable "theNameOnly" and use that in
your WHERE clause.  As an aside, if you want to relieve your users of
the burden of choosing a name, so that they only optionally have to
give the page a unique name, have the name default to
"page_#mypage.ID#", thereby creating "page_123.cfm" by default.  If
the primary name query comes up empty, try to pull out a numeric value
theNameOnly.  This would work:

if (not compareNoCase(listFirst(theNameOnly,"_"),"page") {
theIDOnly=ListLast(theNameOnly,"_");
}

and then search for content with theIDOnly in the WHERE clause.

Now, thats all great but you are going to have a 404 eat you alive
before you even get to ask for the page, unless you write a special
404 handler in the CF Administrator, which you can do and which will
work.  However if you can't do that you can instead build this into
your publishing process:  Copy your dynamic master template named
"show.cfm" physically to a template called "foo.cfm".  That will
create a physical page with the name you need.  Furthermore, "foo.cfm"
will still be a dynamic page, so if you have issues with going to
static content your issues will never come up since foo.cfm has all
the dynamic features of the original, which it is a copy of.

And of course, if your user deletes the page named "foo" your CMS will
have to do the same to the physical, extant "foo.cfm".

I wrote this all up as a generic idea in a CFDJ article back in 2001.
It is here

http://coldfusion.sys-con.com/read/41787.htm

and the process I have described is the "pseudo-static" publication
option in the ContentMonger CMS, which you can download for free here:

http://mysecretbase.com/CMPro_Home.cfm

and that above URL is an example of the pseudo-static process here described.

Most people thought I was crazy when I first wrote the idea up, and I
am sure most people still do, but in the meantime it has happily
served up gazillions of friendly page names over a period of many
years.

Cheers,

-- 
[EMAIL PROTECTED]
Janitor, The Robertson Team
mysecretbase.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266327
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to