Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
martian_iii #1
Fancy URL parsing and variables
I would like to create a site with some easy-to-remember URLs, e.g.
[url]www.mysite.com/about[/url] or [url]www.mysite.com/archives/2005/6/This_is_a_page_title[/url]. Is
there a way to have ColdFusion parse URLs such as these into variables and
values? I am hoping to avoid messy URLs such as
[url]www.mysite.com/archives.cfm?year=2005&month=6&title=This_is_a_pag e_title[/url].
Hopefully this makes sense. I'm aware that some blogging tools do similar
things already, but I think I've only seen this technique work in PHP. I hope
it can be done in ColdFusion as well.
Thanks,
Chris
martian_iii Guest
-
Parsing a url for variables
Suppose I have a url string such as: http://123.com/index.php?value1=This,valueB=that,value7=9 Within index.php of course, I can use $value1,... -
[PHP] URL variables parsing error?
Hi, hiaer@azrael.sk wrote: Try this: <?php echo "var1: {$_GET}"; echo "var2: {$_GET}"; -
URL variables parsing error?
Hi all, I use RedHat9.0 with Apache 2.0.40 & PHP 4.2.2 and I have problem with parsing URL variables... I use this URL:... -
Parsing Variables
I would like to create a script that reads a file name that follows a specific format and have it parsed into 2 variables. The format is as... -
Parsing POST and GET variables simultaneously?
Isn't it possible to get variables from POST and GET simultaneously? Consider the script test.rbx below: require 'cgi' cgi = CGI.new print... -
MattRobertson #2
Re: Fancy URL parsing and variables
Sure. I use that technique myself in a couple of different ways.
For example, this code will give you just the filename of a particular url:
<cfset request.TheNameOnly=ListFirst(ListLast(cgi.Script_ Name,"/"),".")>
So if the url was [url]http://foohbar.com/thisismypage.cfm[/url] the code above would
return the value "thisismypage".
Now lets say you have a CMS with the web page data being stored in a database.
One of the fields is indexed and named "tableName.friendlyName". You would
then do a sql query:
select * from tableName where tableName.FriendlyName='thisismypage'
Poof. Instant friendly url system for a dynamic web site.
Of course I am significantly oversimplifying the picture here (i.e. use
cfqueryparam always; do dupe checks before allowing data into the friendlyName
field) but it should be enough to give you the idea.
If you wanted something 'less firendly' you could use the same parsing code
above, and then find the underscore character and strip out everything to the
left of it. This would make a page named 'page_123.cfm' yield a value of
'123', which would correspond to your primary key in your database. Years ago
I wrote a kinda zany article for CFDJ that illustrated that technique coupled
to some stuff that many people thought was nuts but was then and is now the
only way to solve certain problems on shared hosting.
Hope this helps,
--Matt--
MSB Web Systems... [url]http://mysecretbase.com[/url]
I"Using words to describe magic is like using a screwdriver to cut roast
beef."
- Tom Robbins
MattRobertson Guest
-
martian_iii #3
Re: Fancy URL parsing and variables
Matt,
Thanks for the advice.
I think your suggestion of publishing dummy pages that execute a bit of dynamic code is probably the best way to go. Thanks again.
Chris
martian_iii Guest



Reply With Quote

