Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Classic ASP versions(v3.4.XX)
 How do I change default sortby options for 1 forum
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

TestMagic
Senior Member

USA
1568 Posts

Posted - 24 December 2002 :  15:49:50  Show Profile  Visit TestMagic's Homepage
Here's what I want to do:

Change the default sortby options for a couple of my forums (not all forums) so that all the topics are presented in alphanumeric order (according to title) by default, instead of showing last posts first. I realize of course that my users can do this themselves, but I'd like to do it for them.

Here's why:

My users are building up a base of sample essays, all written on published topics. All these topics have numbers. When we are finished, my users will be able to find the topics easily if they are already in numerical order.

I imagine that this would work well for forums that talk about movies, music, and other such things that have predetermined titles.

Here's what I think:

I looked at forum.asp, and it seems that whatever changes I make there will affect all forums, not just the few forums I want.

So, this would seem to require a MOD, but I wanted to check here first. Actually, I wanted to ask, "Can I change default sortby options for one forum only?" but I didn't want to get a reply that said simply "No."

Snitz rocks! · Search 2

Edited by - TestMagic on 24 December 2002 15:51:04

GauravBhabu
Advanced Member

4288 Posts

Posted - 24 December 2002 :  17:18:58  Show Profile
Can you change the sorting options for one forum?

Well, The answer is No and Yes.

No. Not an option in base code.

Yes, you can. With modifications in following files and addition of a column in table FORUM_FORUM


Instructions posted below. I have not tested the modifications for actual results.


Files to be modified
post.asp
post_info.asp
forum.asp

Step 1:
Database Changes
Add a text field to table FORUM_FORUM

Name the filed as F_TOPIC_SORT_FIELD


Step 2:
post.asp
Add the followings statement block around Line 742


if strRqMethod = "Forum" or _
 strRqMethod = "EditForum" then
 Response.Write	
 "<tr>" & vbNewLine & _
 " <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top""  align=""right"">" & vbNewLine & _
 "  <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
 "   <b>Sort Topics by:</b>" & vbNewLine & _
 "  </font>" & vbNewLine & _
 " </td>" & vbNewLine & _
 " <td bgColor=""" & strPopUpTableColor & """>")

 Response.write (vbNewLine & _
 "<SELECT NAME=""topicsortfield"" style=""font-size:10px;"">" & vbNewLine & _
 "  <OPTION value=""topic""" & CheckSelected(fTopicSortFld, "topic") & ">topic title</OPTION>" & vbNewLine & _
 "  <OPTION value=""author""" & CheckSelected(fTopicSortFld, "author") & ">topic author</OPTION>" & vbNewLine & _
 "  <OPTION value=""replies""" & CheckSelected(fTopicSortFld, "replies") & ">number of replies</OPTION>" & vbNewLine & _
 "  <OPTION value=""views""" & CheckSelected(fTopicSortFld, "views") & ">number of views</OPTION>" & vbNewLine & _
 "  <OPTION value=""lastpost""" & CheckSelected(fTopicSortFld, "lastpost") & ">last post time</OPTION>" & vbNewLine & _
 "</SELECT> " & vbNewLine & _
 "<a href=""Javascript:openWindow3('pop_help.asp?mode=options#topicsortfield')"" tabindex=""-1"">" & getCurrentIcon(strIconSmileQuestion,"Click here to get more help on this option","") & "</a>" & vbNewLine & _
 " </td>" & vbNewLine & _
 "</tr>")
end if



Line 376-379
Add the statement as shown in red



if strRqMethod = "EditForum" then
	fDefaultDays = rs("F_DEFAULTDAYS")
	fForumCntMPosts = rs("F_COUNT_M_POSTS")
        fTopicSortFld = rs("F_TOPIC_SORT_FIELD")
end if


Line 365-368
Modify the sql statement as shown in red
strSql = "SELECT F_SUBJECT, F_URL, F_PRIVATEFORUMS, F_PASSWORD_NEW, " & _
"F_DEFAULTDAYS, F_COUNT_M_POSTS, F_SUBSCRIPTION, F_MODERATION, F_DESCRIPTION, F_TOPIC_SORT_FIELD " & _
"FROM " & strTablePrefix & "FORUM " & _
"WHERE FORUM_ID = " & strRqForumId


Step 3:
post_info.asp
Lines 1342-1343
Add the statement as shown in red
strSql = strSql & ", F_DEFAULTDAYS = " & cLng(Request.Form("DefaultDays"))
strSql = strSql & ", F_TOPIC_SORT_FIELD = '" & ChkString(Request.Form("topicsortfield"),"SQLString") & "'"
strSql = strSql & ", F_COUNT_M_POSTS = " & cLng("0" & Request.Form("ForumCntMPosts"))


Lines 1134-1135
Add the statement as shown in red
strSql = strSql & ", " & ChkString(Request.Form("DefaultDays"), "SQLString")
strSql = strSql & ", " & ChkString(Request.Form("topicsortfield"), "SQLString")
strSql = strSql & ", " & ChkString(Request.Form("ForumCntMPosts"), "SQLString")


Lines 1102-1103
Add the statement as shown in red
strSql = strSql & ", F_DEFAULTDAYS "
strSql = strSql & ", F_TOPIC_SORT_FIELD "
strSql = strSql & ", F_COUNT_M_POSTS "


Step 4:
forum.asp

Add the following procedure around line 902 before the ASP closing tag (%>)

sub SetTopicSortField(strSortField,strtopicsortfld,strSortCol)
    strtopicsortfld = strSortField
    Select Case strSortField
    	Case "topic"
    		strSortCol = "T_SUBJECT" & strSortOrd
    	Case "author"
    		strSortCol = "M_NAME" & strSortOrd
    	Case "replies"
    		strSortCol = "T_REPLIES" & strSortOrd
    	Case "views"
    		strSortCol = "T_VIEW_COUNT" & strSortOrd
    	Case "lastpost"
    		strSortCol = "T_LAST_POST" & strSortOrd
    	Case Else
    		strtopicsortfld = "lastpost"
    		strSortCol = "T_LAST_POST" & strSortOrd
    End Select
end sub


Add the statement as shown in red
Lines 217-219
if strtopicsortfld = "" then
	call SetTopicSortField((rsCFStatus("F_TOPIC_SORT_FIELD")), strtopicsortfld, strSortCol)
end if
if nDays = "" then
        nDays = rsCFStatus("F_DEFAULTDAYS")
end if


Lines 191-199
Modify the statements as shown in red
strSql = "SELECT C.CAT_STATUS, C.CAT_SUBSCRIPTION, " & _ 
	 "C.CAT_MODERATION, C.CAT_NAME, C.CAT_ID, " & _
	 "F.F_STATUS, F.F_SUBSCRIPTION, " & _ 
	 "F.F_MODERATION, F_DEFAULTDAYS, F.F_SUBJECT, F.F_TOPIC_SORT_FIELD " & _
	 " FROM " & strTablePrefix & "CATEGORY C, " & _
	 strTablePrefix & "FORUM F " & _
	 " WHERE F.FORUM_ID = " & Forum_ID & _ 
	 " AND C.CAT_ID = F.CAT_ID " & _
	 " AND F.F_TYPE = 0"

Lines 88-90
Modify the statements as shown below
	Case Else
		strtopicsortfld = "" '"lastpost"
		strSortCol = "" '"T_LAST_POST" & strSortOrd


<edited to add additional changes required in forum.asp>

Edited by - GauravBhabu on 24 December 2002 17:45:38
Go to Top of Page

TestMagic
Senior Member

USA
1568 Posts

Posted - 24 December 2002 :  17:29:26  Show Profile  Visit TestMagic's Homepage
Whoa! That was fast!! I'll try it a little later today to see if I can get it to work.

Thanks, Rakesh. Happy holidays, and happy Diwali a bit late!!

Snitz rocks! · Search 2
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 24 December 2002 :  17:49:01  Show Profile
Thanks TestMagic!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07