<% theme = Request.Cookies("theme") IF theme = "" THEN theme="bg-theme1" END IF ' Get sort parameter (default to lastupdated) Dim sortBy, sortOrder, orderClause sortBy = Request.QueryString("sort") sortOrder = Request.QueryString("order") ' Default sorting (use clicks) If sortBy = "" Then sortBy = "clicks" If sortOrder = "" Then sortOrder = "DESC" ' Get total clicks across all KB articles Dim totalClicksSQL, rsTotalClicks, totalClicks totalClicks = 0 On Error Resume Next totalClicksSQL = "SELECT COALESCE(SUM(clicks), 0) as total_clicks FROM knowledgebase WHERE isactive = 1" Set rsTotalClicks = objConn.Execute(totalClicksSQL) If Not rsTotalClicks.EOF Then totalClicks = CLng(rsTotalClicks("total_clicks")) End If rsTotalClicks.Close Set rsTotalClicks = Nothing On Error Goto 0 ' Build ORDER BY clause based on sort parameter Select Case LCase(sortBy) Case "clicks" orderClause = "ORDER BY kb.clicks " & sortOrder & ", kb.lastupdated DESC" Case "topic" orderClause = "ORDER BY app.appname " & sortOrder Case "description" orderClause = "ORDER BY kb.shortdescription " & sortOrder Case "lastupdated" orderClause = "ORDER BY kb.lastupdated " & sortOrder Case Else ' Default to clicks sorting orderClause = "ORDER BY kb.clicks DESC, kb.lastupdated DESC" End Select %>
Knowledge Base Articles
<%=FormatNumber(totalClicks, 0)%> Total Clicks
Add Article
<% ' Display status messages Dim status, msg status = Request.QueryString("status") msg = Request.QueryString("msg") If status = "added" Then %> <% ElseIf status = "error" Then If msg = "" Then msg = "An error occurred" %> <% End If %>
<% ' Helper function to generate sort link with arrow indicator Function GetSortLink(columnName, displayName, currentSort, currentOrder) Dim newOrder, arrow arrow = "" If LCase(currentSort) = LCase(columnName) Then If UCase(currentOrder) = "DESC" Then newOrder = "ASC" arrow = " " Else newOrder = "DESC" arrow = " " End If Else newOrder = "DESC" End If GetSortLink = "" & displayName & arrow & "" End Function Response.Write("") Response.Write("") Response.Write("") Response.Write("") %> <% strSQL = "SELECT kb.*, app.appname " &_ "FROM knowledgebase kb " &_ "INNER JOIN applications app ON kb.appid = app.appid " &_ "WHERE kb.isactive = 1 " &_ orderClause &_ " LIMIT 10" set rs = objconn.Execute(strSQL) while not rs.eof response.write("") response.write("") ' Trim description to 95 characters Dim description, fullDescription fullDescription = rs("shortdescription") & "" If Len(fullDescription) > 95 Then description = Left(fullDescription, 95) & "..." Else description = fullDescription End If ' Link description directly to the KB article URL (via clickcounter to track clicks) response.write("") response.write("") ' Add info icon that links to the article details page response.write("") response.write("") rs.movenext wend objConn.Close %>
" & GetSortLink("topic", "Topic", sortBy, sortOrder) & "" & GetSortLink("description", "Description", sortBy, sortOrder) & "" & GetSortLink("clicks", "Clicks", sortBy, sortOrder) & "
" &Server.HTMLEncode(rs("appname")) &"" &Server.HTMLEncode(description) &"" &rs("clicks") &"