|
<!-- #INCLUDE FILE="FAQCONFIG.inc" -->
<!-- #INCLUDE FILE="DBCONNECT.inc" -->
<!-- #INCLUDE FILE="Constants.inc" -->
<%
' ************************************************************************************************
'EzFAQ - Version 1.0
'
'Written By: Copyright 2001
' George Chastain
' Huntsville, Alabama
' Website: http://home.hiwaay.net/~georgech/
'
' You are free to use this code for any purpose but please retain the author and copyright
' information. If you make any enhancements to this code, I would like to know about them.
' You can reach me through my website address above.
'
' Thank you.
'
'SOURCE FILE: showfaqs.inc
'DESCRIPTION: This file will display the FAQs in the FAQ List. The default is to display only
' the FAQ Titles. This ASP file is also called when the user selects a FAQ
' to display the FAQ Text for the selected FAQ. This file is also called when the
' user selects to display the "Printer Friendly" version of the FAQ list where the text
' for ALL FAQs is displayed.
'
' To add a FAQ list to your site, simply include this file where desired in your
' ASP page.
'
'Modifications:
'
'9 June 2001 Initial Creation
' ************************************************************************************************
Dim FAQTitle ' Title of the FAQ entry
Dim FAQ ' The text of the FAQ entry
Dim FAQqID ' FAQ ID passed in by the Query String
Dim sData ' Stores a record read from the FAQ text file.
Dim objRS
Dim objConn
Dim FAQID
Dim strSQL
Dim strFAQTitle
' ******************************************************
' ******************************************************
'Uncomment these if using ASP 3.0
'Session.Contents.Remove("myFAQTitle")
'Session.Contents.Remove("myFAQ")
' ******************************************************
' ******************************************************
strPath = Server.MapPath(FAQFile)
DBConnect(strPath)
' Set objRS = Server.CreateObject("ADODB.Recordset")
' objRS.Open FAQTable , objConn
'Create SQL statement to load the record for the specified FAQ to be edited.
strSQL = "SELECT * FROM " & FAQTable & " ORDER BY FAQTitle DESC"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic
'Get the FAQ ID (if any) passed in via the Query String
FAQqID = Request.QueryString("FAQ")
'Begin FAQ List Table.
Response.Write("<table BORDER=""" & FAQListTableBorderSize & """ WIDTH=""100%"" CELLSPACING=""" & FAQListTableCellSpacing & """ CELLPADDING=""" & FAQListTableCellPadding & """>" & vbCrLf)
Response.Write("<tr>" & vbCrLf)
Response.Write("<td WIDTH=""100%"" BGCOLOR=""" & FAQListTableHeaderColor & """ valign=""top"">" & vbCrLf)
Response.Write("<table BORDER=""0"" CELLSPACING=""0"" CELLPADDING=""0"" WIDTH=""100%"">" & vbCrLf)
Response.Write("<tr>")
Response.Write("<td WIDTH=""50%"" align=""left"" valign=""top"">" & vbCrLf)
Response.Write("<font SIZE=""2""><a HREF=""showfaqs.asp""><img border=""0"" src=""ezfaq.gif"" ALT=""Show FAQ List"" width=""32"" height=""32"" align=""middle""></a></font>" & vbCrLf)
Response.Write("<font SIZE=""5"">" & FAQListName & vbCrLf)
Response.Write("</td>" & vcCrLf)
Response.Write("<td WIDTH=""50%"" align=""right"" valiagn=""top"">" & vbCrLf)
if EnableCreate = true then
Response.Write("<font SIZE=""2""><a HREF=""enterfaq.asp""><img border=""0"" src=""note.gif"" ALT=""Enter a new FAQ"" width=""32"" height=""32""></a></font>" & vbCrLf)
end if
Response.Write("<font SIZE=""2""><a HREF=""showfaqs.asp?Title=Printer Friendly""><img border=""0"" src=""PrinterFriendly.gif"" ALT=""Display Printer Friendly List"" width=""32"" height=""32""></a></font>" & vbCrLf)
Response.Write("</td>" & vbCrLf)
Response.Write("</tr>")
Response.Write("</table>")
Response.Write("</td>" & vbCrLf)
Response.Write("</tr>" & vbCrLf)
'Begin row of main FAQ List Table that will contain tables for each FAQ entry.
Response.Write("<tr><td width=""100%"" valign=""top"" BGCOLOR=""" & FAQListTableBodyColor & """>" & vbCrLf)
'Check to see if the file exists before processing.
if objRS.RecordCount > 0 then
Response.Write("<font SIZE=""2""><b>" & objRS.RecordCount & " FAQs</b></FONT>" & vbCrLf)
'FAQ List Table
'The file exists, start printing out the FAQs from the text file.
do while not objRS.EOF
'The records consist of two fields. The first field is the FA Q Title, the
'second field is the FAQ text itself. The two fields are separated by a SINGLE
'TAB character. You can update/modify the FAQ file using a plain text editor
'or Microsoft Excel which can import/export spreadsheets as a tab-delimited
'text file.
FAQID = objRS("ID")
strFAQTitle = objRS("FAQTitle")
Response.Write("<table BORDER=""" & FAQEntryTableBorderSize & """ CELLPADDING=""" & FAQEntryTableCellPadding & """ CELLSPACING=""" & FAQEntryTableCellSpacing & """WIDTH=""" & FAQEntryTableWidth & """>" & vbCrLf)
Response.Write(" <tr>" & vbCrLf)
' If the Query String is not null, then we want to print one or more of the FAQ entry's text.
if not IsEmpty(FAQqID) then
if StrComp(FAQqID,FAQID,1) = 0 then
'If we want to display the text for a single FAQ, then highlight the selected FAQ's title.
Response.Write(" <td WIDTH=""100%"" BGCOLOR=""" & FAQEntryTableHeaderColor & """>" &vbCrLf)
else
'Either we didn't select the current FAQ for display and so do not want to highlight the FAQ title
'or we are printing the "Printer Friendly" version of the page and will not be highlighting ANY FAQ title.
Response.Write(" <td WIDTH=""100%"">" &vbCrLf)
end if
else
'We do not want to highlight the FAQ title for this record
Response.Write(" <td WIDTH=""100%"">" &vbCrLf)
end if
'Write out the FAQ Title.
Response.Write("<A NAME=""F" & FAQID & """></a>" & vbCrLf)
Response.Write("<font SIZE=""" & FAQEntryTitleFontSize & """>" & "<a HREF=""showfaqs.asp?FAQ=" & FAQID & "#F" & FAQID & """>" & objRS("FAQTitle") & "</a>" & vbCrLf)
if EnableEdit = true then
Response.Write("<font SIZE=""" & FAQEntryTitleFontSize & """>" & "<a HREF=""editfaq.asp?FAQ=" & FAQID & """><img border=""0"" src=""doc.gif"" ALT=""Edit FAQ"" width=""12"" height=""12""></a>"& vbCrLf)
end if
if EnableDelete = true then
Response.Write("<font SIZE=""" & FAQEntryTitleFontSize & """>" & "<a HREF=""ConfirmDelete.asp?FAQTitle=" & strFAQTitle & "&FAQ=" & FAQID & """><img border=""0"" src=""deldoc.gif"" ALT=""Delete FAQ"" width=""12"" height=""12""></a>"& vbCrLf)
end if
Response.Write("</font></td></tr>" & vbCrLf)
if StrComp(FAQqID,"Printer Friendly",1) = 0 then
'We want to display the "Printer Friendly" version of the page in which
'each FAQ is to have its text displayed (not just the title).
Response.Write("<tr>" & vbCrLf)
Response.Write(" <td WIDTH=""100%"">" &vbCrLf)
Response.Write("<font SIZE=""" & FAQEntryTextFontSize & """ COLOR=""" & FAQEntryTextColor & """>" & vbCrLf)
'Write out the FAQ Text.
Response.Write(objRS("FAQText") & "</font>" & vbCrLf)
Response.Write("" & vbCrLf)
Response.Write("</td></tr>" & vbCrLf)
else
'We are NOT displaying the "Printer Friendly" version of the page. So we
'need to check to see if one has been selected to display.
if not IsEmpty(FAQqID) then
'A FAQ ID was passed to this page via the Query String. Check to
'see if it is equal to the current FAQ's ID that is being processed for display.
if StrComp(FAQqID,FAQID,1) = 0 then
'The current FAQ has been selected for expansion of its text.
'Print the current FAQ's full text.
Response.Write("<tr>" & vbCrLf)
Response.Write(" <td WIDTH=""100%"">" &vbCrLf)
Response.Write("<font SIZE=""" & FAQEntryTextFontSize & """ COLOR=""" & FAQEntryTextColor & """>" & vbCrLf)
'Write out the FAQ Text.
Response.Write(objRS("FAQText") & "</font>" & vbCrLf)
Response.Write("" & vbCrLf)
Response.Write("</td></tr>" & vbCrLf)
end if
end if
end if
Response.Write("</table>" & vbCrLf)
objRS.MoveNext
loop
'Close the FAQ text file.
else
'The FAQ db is empty.
Response.Write("No one has submitted any FAQs at this time.")
end if
objRS.Close
Set objRS = Nothing
'Close the FAQ db
DBClose
Response.Write("</td></tr>" & vbCrLf)
Response.Write("<tr><td WIDTH=""100%"" ALIGN=""left""><font SIZE=""1""><b>EzFAQ -- Copyright 2001 George Chastain</b></font></td></tr></table>" & vbCrLf)
%>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
George Chastain is a Software Consultant in Huntsville, Alabama. Mr. Chastain is experienced in all phases of the software development life cycle including requirements analysis and definition, design, coding and test. This experience spans both interactive applications and embedded software. Mr. Chastain has extensive experience in C/C++ (including Visual C++), Ada 83, Ada 95 (including real-time, safety-critical), FORTRAN and other languages on Windows and Unix platforms. (Web development is JUST a hobby.)
Other articles authored by Mr. Chastain may be found at www.codeguru.com, a Windows development site, and at www.geocomm.com, a site supporting the GIS and GPS communities.