Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Developing a Forum In CF

Status
Not open for further replies.

RussM

Programmer
May 12, 1999
5
0
0
US
<br>
I am interested in coding a forum type messageing system (similar to this one here) and would like to have some input as to how to get started in this project. As you might ascertain, I am pretty new at this and would<br>
appreciate any upfront help in starting out correctly. The data base will be used by engineers on different projects, with ability to comment to each other on those projects. Also, has anyone seen any good cf chat<br>
systems? "Barebone" code/DB layout wouldbe most helpful.<br>
<br>
rmahan@us.hsanet.net
 
Are you setting up one forum, or a group of forums?<br>
<br>
If you are setting up one, basically all you need is two tables, one for questions, and one for answers.<br>
<br>
The question table should have (at minimum) columns for:<br>
Question ID (An autonumbered key index)<br>
UserName<br>
Subject<br>
Body<br>
Date<br>
<br>
The answer table should have columns for:<br>
Question ID (Referencing the question table)<br>
UserName<br>
Body<br>
Date<br>
<br>
Be sure to allow enough space in your body columns to allow your users to post without having to worry about their stuff being truncated.<br>
<br>
Posting is fairly simple. Just set up a form similar to this one.<br>
<br>
&lt;form action=nextpage.cfm method=post&gt;<br>
&lt;input type="text" name="UserName" size=10&gt;&lt;br&gt;<br>
&lt;input type="text" name="Subject" size=80&gt;&lt;br&gt;<br>
&lt;textarea rows=5 cols=50 name="body"&gt;post goes here&lt;/textarea&gt;<br>
&lt;input type=submit value="submit"&gt;<br>
&lt;/form&gt;<br>
<br>
<br>
<br>
To process this form, use a query on the "nextpage.cfm" accordingly...<br>
<br>
&lt;cfquery name="post" datasource="mydb"&gt;<br>
insert into questions (UserName,Subject,Body,Date)<br>
Values (#Form.UserName#,#Form.Subject#,#Form.Body#,#Form.Date#)<br>
&lt;/cfquery&gt;<br>
<br>
To display the questions, I would sort them descending by date, like:<br>
<br>
&lt;cfquery name="getquestion" datasource="mydb"&gt;<br>
select * from answers<br>
order by date desc<br>
&lt;/cfquery&gt;<br>
<br>
&lt;cfoutput query="getquestion"&gt;<br>
&lt;p&gt;#UserName# #Date#&lt;br&gt;<br>
&lt;a href="replies.cfm?QuestionID=#QuestionID#"&gt;#Subject#&lt;/a&gt;&lt;/p&gt;<br>
&lt;/cfoutput&gt;<br>
<br>
Then on replies.cfm you should output the full question, followed by the responses sorted by date ascending:<br>
<br>
&lt;cfquery name="getquestion" datasource="mydb"&gt;<br>
select * from questions<br>
where QuestionID=#QuestionID# &lt;!----passed from the previous page ---&gt;<br>
&lt;/cfquery&gt;<br>
<br>
&lt;cfquery name="getreplies" datasource="mydb"&gt;<br>
select * from replies<br>
where QuestionID=#QuestionID#<br>
order by date<br>
&lt;/cfquery&gt;<br>
<br>
&lt;cfoutput query="getquestion"&gt;<br>
#UserName# #date#&lt;br&gt;<br>
#Subject#&lt;br&gt;<br>
#Body#<br>
&lt;/cfoutput&gt;<br>
&lt;cfoutput&gt; query="getreplies" datasource="mydb"&gt;<br>
#UserName# #date#&lt;br&gt;<br>
#Body#<br>
&lt;/cfoutput&gt;<br>
<br>
To reply to this, use a form similar to the question, but use a hidden input parameter for the questionID..<br>
<br>
&lt;form action=nextpage.cfm method=post&gt;<br>
&lt;cfoutput&gt;&lt;input type="hidden" name="QuestionID" value="#getquestion.QuestionID#"&gt;&lt;/cfoutput&gt; &lt;!---Always remember to put paramters inside &lt;cfoutputs&gt;!! ---&gt;<br>
&lt;input type="text" name="UserName" size=10&gt;&lt;br&gt;<br>
&lt;textarea rows=5 cols=50 name="body"&gt;post goes here&lt;/textarea&gt;<br>
&lt;input type=submit value="submit"&gt;<br>
&lt;/form&gt;<br>
<br>
Processing this is also similar to the questions....<br>
<br>
&lt;cfquery name="post" datasource="mydb"&gt;<br>
insert into replies (QuestionID,UserName,Body,Date)<br>
Values (#Form.QuestionID#,#Form.UserName#,#Form.Body#,#Form.Date#)<br>
&lt;/cfquery&gt;<br>
<br>
Obviously, you will need to come up with an interface to make this all look pretty...:)<br>
<br>
Let me know if this helps, or if you need any further assistance...<br>
<br>
- Doug
 
Thanks Doug,<br>
I have began putting one together. I need to have this for several different topics or forums. I will begin to work on what you have given me here and let you know how it goes. I will give you the URL once I get something working.<br>
<br>
I work for DoD, so there is no profit being made here. I notice there are lots and lots of perl, asp and of course Java Applets out there, but not much in cold fusion (as far as message threads are concerned). I have seen many good ones out there and would like to emulate them in design. One is the "raging bull" ( site, it has an excellent set up for message threads.<br>
<br>
again, thanks for getting me started.<br>
<br>
Russ Mahan
 
Let me know if I can be of any further assistance.
 
Doug,<br>
How would I make use of what I now have (a single forum) and develop several forums to choose from. Do I need another table that just keeps track of the ForumID?<br>
<br>
Russ
 
Yep. Just a table with a list of forum names and a ForumID. Then, on the question table, just add a ForumID to reference the Forum.....<br>
<br>
To select the questions for a particular forum:<br>
<br>
&lt;cfquery name="getquestion" datasource="mydb"&gt;<br>
select * from questions<br>
where questions.ForumID=Forums.ForumID<br>
order by date desc<br>
&lt;/cfquery&gt;
 
Doug,<br>
I cant seem to get this to work with more than one forum.<br>
<br>
I have quite a bit of code, could I possibly email my delima and have you take a look at it?<br>
<br>
Russ
 
has a great chat program ! You can download it to test it out FREE ! It's called Fusion Chat !<br>
As far as forums...Allaire has a product called Forums. I'm sure the purchase price would be offsite by the time it would take to develop something similar.
 
alternatively.... u can look into developing using<br>
PHP... <br>
<br>
think they have a 'PHORUM' done using PHP...<br>

 
One thing about this forum is that it does not<br>
have security.<br>
<br>
I can easily change my handle and vote for myself<br>
thru' another person's handle.
 
I just downloaded CF Express for testing and it comes with a sample forum you may be able to build upon. Its in the GlobalCorp sample.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top