Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumSearch Returns Blank PageSearch Returns Blank Page
Previous
 
Next
New Post
2/23/2007 5:50 AM
 
This might have already come up so if there is a fix please just point me to it - I looked about for 15 min or so and didnt seem to see anything.

Anyways...

When I do a forum search it returns a blank page. Likewise - if I view a user profile then click "view all posts for this user" it also returns a blank page (that would make sense duh)

On my test system on my local box it works just fine which is interesting. So I know it works OK just on my hosted customers site it returns nothing. This would seem to indicate a SQL issue?

Do I need to re-run scripts or something to get things lined up correctly etc?

Anyone else run into this?

 
New Post
2/23/2007 7:38 PM
 

OK so I solved my own problem - below is a fix for the Forum_SearchGetResults script. The original attempted to order by on a column that is not part of the select statement - the original script worked ok on my test box but not on my isp's server.

There were also 2 PRINT statements commented out that I highly recommend NEVER leaving in production code - I will sometimes surround prints with a @verbose check or something so they dont fire unless that parm has a value etc.... other wise I always try to remember to remove them.

 

The stuff I did is bolded.


ALTER PROCEDURE [yourid].[Forum_SearchGetResults]
(
@Filter nvarchar(500),
@PageIndex int,
@PageSize int,
@UserID int,
@ModuleID int,
@FromDate datetime,
@ToDate datetime
)
AS
-- Create a temp table to store the select results
CREATE TABLE #PageIndex
(
IndexID int IDENTITY (1, 1) NOT NULL,
ThreadID int
)
-- Create dynamic SQL to populate temporary table
DECLARE @sql nvarchar(2000)
SELECT @sql = 'INSERT INTO #PageIndex(ThreadID) SELECT DISTINCT(P.ThreadID) ' +
--SELECT @sql = 'INSERT INTO #PageIndex(ThreadID) SELECT DISTINCT (P.ThreadID) CreatedDate ' +
'FROM Forum_Posts P ' +
'INNER JOIN Forum_Threads T ON P.ThreadID = T.ThreadID ' +
'INNER JOIN Forum_Forums F ON T.ForumID = F.ForumID ' +
'INNER JOIN Forum_Groups G ON F.GroupID = G.GroupID ' +
'INNER JOIN Forum_Posts LP ON T.ThreadID = LP.ThreadID ' +
'WHERE P.ThreadID = T.ThreadID AND ' +
'T.ForumID = F.ForumID AND ' +
'F.GroupID = G.GroupID ' +
'AND P.[CreatedDate] > ''' + CONVERT(varchar, @FromDate) + ''' ' +
'AND P.[CreatedDate] < ''' + CONVERT(varchar, @ToDate) + ''' ' +
'AND P.IsApproved = 1 ' +
'AND P.IsLocked = 0 ' +
'AND G.ModuleID = ' + CONVERT(varchar, @ModuleID) + ' AND ' +

'( F.ForumID NOT IN (SELECT ForumID FROM Forum_PrivateForums) OR ' +
' F.ForumID IN ( ' +
'SELECT ForumID ' +
'FROM Forum_PrivateForums (nolock) ' +
'WHERE (RoleID IN (SELECT RoleID FROM UserRoles WHERE UserID = ' + CONVERT(varchar, @UserID) + ' ) ' +
'OR EXISTS (SELECT TOP 1 1 FROM Users WHERE UserID = ' + CONVERT(varchar, @UserID) + ' and IsSuperUser=1)))) ' +
@Filter + ' GROUP BY P.ThreadID , P.CreatedDate' -- ORDER BY P.CreatedDate DESC '
--Print @sql
EXEC(@sql)
-- All of the rows are inserted into the table - now select the correct subset
DECLARE @PageLowerBound int
DECLARE @PageUpperBound int
DECLARE @RecordCount int
-- Set the page bounds
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1
SELECT @RecordCount = COUNT(*) FROM #PageIndex

--Print @RecordCount
-- Select the data out of the temporary table
-- Select the data out of the temporary table
SELECT
PageIndex.ThreadID,
P.[Subject],
P.[CreatedDate],
FU.[UserID],
FU.[Alias],
T.[ForumID],
T.[Replies],
T.[Views],
F.[Name] As ForumName,
RecordCount = @RecordCount,
(SELECT Count([ThreadID]) FROM Forum_ThreadRating WHERE ThreadID = PageIndex.ThreadID) As RatingCount,
(SELECT AVG([Rate]) FROM Forum_ThreadRating WHERE ThreadID = PageIndex.ThreadID) As Rating,
(SELECT Distinct Count(UserID) FROM Forum_ThreadsRead WHERE ForumID = T.[ForumID] AND UserID = FU.[UserID] AND P.[CreatedDate] > LastPurseDate AND ReadThreads NOT LIKE '%' + CONVERT(varchar, PageIndex.ThreadID) + ';%') As IsUnRead
FROM
Forum_Posts P
INNER JOIN Forum_Threads T ON P.ThreadID = T.ThreadID
INNER JOIN Forum_Forums F ON T.ForumID = F.ForumID
INNER JOIN Forum_Users FU ON P.UserID = FU.UserID, #PageIndex PageIndex
WHERE
PageIndex.IndexID > @PageLowerBound AND
PageIndex.IndexID < @PageUpperBound AND
PageIndex.ThreadID = P.ThreadID AND
FU.[UserID] = P.[UserID] AND
P.[ThreadID] = T.[ThreadID] AND
P.[CreatedDate] > @FromDate AND
P.[CreatedDate] < @ToDate AND
T.[ForumID] = F.[ForumID] AND
(P.[CreatedDate] = (SELECT MAX([CreatedDate]) FROM Forum_Posts WHERE ThreadID = PageIndex.ThreadID)) AND
(F.ForumID NOT IN (SELECT ForumID FROM Forum_PrivateForums) OR
F.ForumID IN (
SELECT ForumID
FROM Forum_PrivateForums
WHERE (RoleID IN (SELECT RoleID FROM UserRoles WHERE UserID = @UserID)
OR EXISTS (SELECT TOP 1 1 FROM Users WHERE UserID = @UserID and IsSuperUser=1))))
ORDER BY
P.[CreatedDate] DESC

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumSearch Returns Blank PageSearch Returns Blank Page


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out