IBM developerWorks
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 7th, 2004, 05:47 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Generating pages off database dynamically

sup ppl,

how would I generate 'static' pages off database on demand in coldfusion?

for example, when user clicks on a link, it will take the user to a page named after the row number of the entry in the database table, e.g. 189.cfm or 200045.cfm, etc... and these pages being generated on demand? then maybe cached for 10-20 minutes and save space?

am I thinking too hard?
Is it as simple as using cffile tag?

Reply With Quote
  #2  
Old October 7th, 2004, 06:29 PM
bocmaxima's Avatar
bocmaxima bocmaxima is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2004
Location: Tucson, Sonora
Posts: 1,322 bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 17 h 46 m 5 sec
Reputation Power: 22
Send a message via AIM to bocmaxima
Yes, you can use <cffile action="write"> for this along with the required parameters.
As for writing cfm files, you may encounter issues if you want to include CF tags, although I think it will still work since you're pulling from a database and CF should then ignore them.
In these sort of situations, it really is easier to use URL variables. But if you really want that, it's very do-able.

Hope that helps.

Reply With Quote
  #3  
Old October 7th, 2004, 08:20 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
You can use cffile to write static HTML files. You can also cache the query results using <cfquery> or caching data into the session or application scopes.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #4  
Old October 7th, 2004, 09:54 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
i see..

what if there will be thousands of pages? I'm wondering if going this route will be easier on the server, and faster for users, than to have a handful of pages getting all the hits...

Reply With Quote
  #5  
Old October 8th, 2004, 09:04 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
The real question is, do you need to do this? Is your traffic high enough that you have determined that using dynamic CF pages is too slow, and that you need to generate static HTML pages instead? Yes, static HTML pages are served faster than CF pages because CF isn't doing anything, but the difference is rather small and unless you're under a very heavy load I doubt it would make much of a difference, assuming that you have a decent server, a decent database, and properly written SQL and CFML code.

Reply With Quote
  #6  
Old October 17th, 2004, 02:31 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
ah...

kiteless, do you recommend any book or an article on the web that may discuss something of this nature?

thnx!

Reply With Quote
  #7  
Old October 17th, 2004, 07:28 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
I can't give a specific recommendation, but I believe Ben Forta's book at least touches on this topic. In reality, the best thing to do would be to try it yourself. Something like this:
  1. Query the database for the dynamic info
  2. Compose what you want to show up on the final page
  3. Loop over the query and create the dynamic output, and use the <cfsavecontent> tag around your loops or cfoutputs to capture the final output HTML
  4. With all the content captured in a variable, save that final variable (all the static HTML code) to your server with cffile
  5. Since you're looping over the query, this will generate the output and save a file for each record in the query

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Generating pages off database dynamically


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway