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

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Article Nav in David's Portal Mod
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

StephenD
Senior Member

Australia
1044 Posts

Posted - 14 December 2003 :  03:53:57  Show Profile  Send StephenD a Yahoo! Message
I need some help debugging this sub to enable Next/Previous navigation in the footer of each article in David's Portal.

I've nearly got it. When you call the following sub it seems to only show the icon for previous article and only go to one particular article:

Sub Article_nav()

dim strSql
dim rsArticle
strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
set rsArticle = Server.CreateObject("ADODB.Recordset")
rsArticle.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
Article_Date = rsArticle("CONT_DATE")
ContentID = rsArticle("CONT_ID")
CategoryID = rsArticle("CAT_ID")

		
if prevArticle = "" then
				
		strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
		strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
		strSql = strSql & "WHERE CONT_DATE >'" & Article_Date   
		strSql = strSql & "'AND CAT_ID=" & CategoryID
		strSql = strSql & " ORDER BY CONT_DATE;"


		set rsPrevArticle = my_conn.Execute(TopSQL(strSql,1))

		if rsPrevArticle.EOF then
			prevArticle = getCurrentIcon(strIconBlank,"","align=""top"" hspace=""6""")
		else
		  '##### Next/Prev Topic Title Hover MOD #####
		       prevArticle = "<a href=""portal.asp?" & "ContentID="& rsPrevArticle("CONT_ID") & "&CategoryID="& rsPrevArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoLeft,"" & "Previous Article: " & chkString(rsPrevArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
		  '###########################################
		end if

		rsPrevArticle.close
		set rsPrevArticle = nothing
	else
		prevArticle = prevArticle
	end if

	

	if NextArticle = "" then
		strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
		strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
		strSql = strSql & "WHERE CONT_DATE < '" & Article_Date   
		strSql = strSql & "'AND CAT_ID=" & CategoryID
		strSql = strSql & " ORDER BY CONT_DATE DESC;"
		
		set rsNextArticle = my_conn.Execute(TopSQL(strSql,1))

		if rsNextArticle.EOF then
			nextArticle = getCurrentIcon(strIconBlank,"","align=""top"" hspace=""6""")
		else
		  '##### Next/Prev Topic Title Hover MOD #####
		NextArticle = "<a href=""portal.asp?" & "ContentID="& rsNextArticle("CONT_ID") & "&CategoryID="& rsNextArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoRight,"" & "Next Article: " & chkString(rsNextArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
		  '###########################################
		end if

		rsNextArticle.close
		set rsNextArticle = nothing
	else
		nextArticle = nextArticle
	end if

	Response.Write ("                " & prevArticle & "<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """>Articles </font>" & nextArticle)
rsArticle.close
set rsArticle = nothing 
end sub


All help would be sincerely appreciated. Thanks.

Edited by - StephenD on 14 December 2003 11:17:16

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  11:36:54  Show Profile
where are you setting the prevArticle and NextArticle variables?

The UK MkIVs Forum
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  11:42:08  Show Profile
your first sql statement shouldn't be needed, you can pick up the ContentID and CategoryID from the querystring, you can also pass the current articles date into the sub from the DisplayContent sub

The UK MkIVs Forum
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 14 December 2003 :  12:09:28  Show Profile  Send StephenD a Yahoo! Message
quote:
Originally posted by DavidRhodes

your first sql statement shouldn't be needed, you can pick up the ContentID and CategoryID from the querystring, you can also pass the current articles date into the sub from the DisplayContent sub



Do you mean like - inserting this into the SubDisplayContentItem after the SQL query:
Dim ArticleDate
ArticleDate = rsContent.Fields("CONT_DATE").Value
?
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  12:22:57  Show Profile
sub DisplayContentItem(byval ContentID, byval ContentCategoryID)

	dim strSql, rsContent	
	
	strSql = "SELECT " 
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_ID, "
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CAT_ID, " 
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_TITLE, " 
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_BODY, "
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_DATE, " 
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_AUTHOR, " 
	strSql = strSql & strTablePrefix & "CMS_CONTENT.CONT_LAST_EDIT "
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE " & strTablePrefix & "CMS_CONTENT.CONT_ID = " & ContentID
		
	set rsContent = my_Conn.Execute(strSql)
	
	call StartTable("100%", rsContent.Fields("CONT_TITLE").Value)
	
	Response.Write formatStr(rsContent.Fields("CONT_BODY").Value) &"<br /><br />"& vbCrLf &_
			"Author: <a href=""pop_profile.asp?mode=display&id="& rsContent.Fields("CONT_AUTHOR").Value & """>"& getMemberName(rsContent.Fields("CONT_AUTHOR").Value) & "</a><br />" &_
			"Posted: "& ChkDate(rsContent.Fields("CONT_DATE").Value, "</b>" ,true) &vbCrLf
			
	If StrComp(rsContent.Fields("CONT_DATE").Value, rsContent.Fields("CONT_LAST_EDIT").Value, vbTextCompare) <> 0 then
		Response.Write  "<br />Edited: "& ChkDate(rsContent.Fields("CONT_LAST_EDIT").Value, "</b>" ,true) &vbCrLf
	end if
	
	call DisplayArticleNavigation(ContentID, rsContent("CAT_ID"), rsContent("CONT_LAST_EDIT"))
	
	set rsContent = nothing
	
	call EndTable()
			
end sub

changes in red
Sub DisplayArticleNavigation(byval ContentID, byval CategoryID, byval CurrentArticleDate)

	dim strSql
	dim rsPrevArticle, rsNextArticle
			
	'Previous Article			
	strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT < '" & CurrentArticleDate  
	strSql = strSql & "' AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT ASC"

	set rsPrevArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsPrevArticle.EOF then
       prevArticle = "<a href=""portal.asp?ContentID="& rsPrevArticle("CONT_ID") & "&CategoryID="& rsPrevArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoLeft,"" & "Previous Article: " & chkString(rsPrevArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsPrevArticle.close
	set rsPrevArticle = nothing

	'Next Article
	strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT > '" & CurrentArticleDate   
	strSql = strSql & "'AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT ASC"
		
	set rsNextArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsNextArticle.EOF then
		nextArticle = "<a href=""portal.asp?ContentID="& rsNextArticle("CONT_ID") & "&CategoryID="& rsNextArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoRight,"" & "Next Article: " & chkString(rsNextArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsNextArticle.close
	set rsNextArticle = nothing

	Response.Write ("<br />" & prevArticle & nextArticle)

end sub

The UK MkIVs Forum
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  12:25:24  Show Profile
next article is working, previous isn't, will try and fix it

The UK MkIVs Forum
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  12:27:35  Show Profile
fixed

Sub DisplayArticleNavigation(byval ContentID, byval CategoryID, byval CurrentArticleDate)

	dim strSql
	dim rsPrevArticle, rsNextArticle
			
	'Previous Article			
	strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT < '" & CurrentArticleDate  
	strSql = strSql & "' AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT DESC"

	set rsPrevArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsPrevArticle.EOF then
       prevArticle = "<a href=""portal.asp?ContentID="& rsPrevArticle("CONT_ID") & "&CategoryID="& rsPrevArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoLeft,"" & "Previous Article: " & chkString(rsPrevArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsPrevArticle.close
	set rsPrevArticle = nothing

	'Next Article
	strSql = "SELECT CONT_TITLE, CONT_ID, CAT_ID, CONT_DATE  " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT > '" & CurrentArticleDate   
	strSql = strSql & "'AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT ASC"
		
	set rsNextArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsNextArticle.EOF then
		nextArticle = "<a href=""portal.asp?ContentID="& rsNextArticle("CONT_ID") & "&CategoryID="& rsNextArticle("CAT_ID") & """>" & getCurrentIcon(strIconGoRight,"" & "Next Article: " & chkString(rsNextArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsNextArticle.close
	set rsNextArticle = nothing

	Response.Write ("<br />" & prevArticle & nextArticle)

end sub

The UK MkIVs Forum
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 14 December 2003 :  12:30:37  Show Profile  Send StephenD a Yahoo! Message
Perfect, thank you very much David. You wouldn't believe the hours I've spent trial'n'error on this. Still believe I'm actually learning something ... well, I have to maintain that belief!!!

Cheers!
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 14 December 2003 :  12:32:07  Show Profile
change to this, just removed some unnecessary code from the select statements

Sub DisplayArticleNavigation(byval ContentID, byval CategoryID, byval CurrentArticleDate)

	dim strSql
	dim rsPrevArticle, rsNextArticle
			
	'Previous Article			
	strSql = "SELECT CONT_TITLE, CONT_ID " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT < '" & CurrentArticleDate  
	strSql = strSql & "' AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT DESC"

	set rsPrevArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsPrevArticle.EOF then
       prevArticle = "<a href=""portal.asp?ContentID="& rsPrevArticle("CONT_ID") & "&CategoryID="& CategoryID & """>" & getCurrentIcon(strIconGoLeft,"" & "Previous Article: " & chkString(rsPrevArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsPrevArticle.close
	set rsPrevArticle = nothing

	'Next Article
	strSql = "SELECT CONT_TITLE, CONT_ID " 
	strSql = strSql & "FROM " & strTablePrefix & "CMS_CONTENT "
	strSql = strSql & "WHERE CONT_LAST_EDIT > '" & CurrentArticleDate   
	strSql = strSql & "'AND CAT_ID=" & CategoryID
	strSql = strSql & " ORDER BY CONT_LAST_EDIT ASC"
		
	set rsNextArticle = my_conn.Execute(TopSQL(strSql,1))
	if NOT rsNextArticle.EOF then
		nextArticle = "<a href=""portal.asp?ContentID="& rsNextArticle("CONT_ID") & "&CategoryID="& CategoryID & """>" & getCurrentIcon(strIconGoRight,"" & "Next Article: " & chkString(rsNextArticle("CONT_TITLE"),"imagetag") & "","align=""top"" hspace=""6""") & "</a>"
	end if
	rsNextArticle.close
	set rsNextArticle = nothing

	Response.Write ("<br />" & prevArticle & nextArticle)

end sub

The UK MkIVs Forum
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