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 ForumsReportsReportsMore refined "most recent posts" reportMore refined "most recent posts" report
Previous
 
Next
New Post
5/12/2009 7:53 PM
 

I saw the example above showing using a "most recent posts" type of query. I've refined that a bit to use the current login to display posts according to access rules rather than restricting things by forums in a "private" group.

SQL:

SELECT TOP 5
     Forum_Forums.ForumID as 'ForumID'
    ,Forum_Threads.ThreadID as 'ThreadID'
    ,Forum_Posts.Subject as 'Subject'
    ,Forum_Posts.UpdatedDate as 'UpdatedDate'
    ,Users.DisplayName as 'DisplayName'
FROM
    Forum_Posts
    INNER JOIN Forum_Threads ON Forum_Posts.ThreadID = Forum_Threads.ThreadID
    INNER JOIN Forum_Forums ON Forum_Threads.ForumID = Forum_Forums.ForumID
    INNER JOIN Forum_Groups ON Forum_Forums.GroupID = Forum_Groups.GroupID
    INNER JOIN dbo.Users ON Forum_Posts.UserID = dbo.Users.UserID
WHERE
    Forum_Groups.PortalID = @PortalID
    AND Forum_Forums.IsActive = '1'
    AND Forum_Posts.IsApproved = '1'
    AND (
        Forum_Forums.PublicView = 1
        OR Forum_Forums.ForumID in (
            SELECT ForumID
            FROM dbo.Forum_ForumPermission
            WHERE
                AllowAccess = 1
                AND (
                    RoleID IN ( Select RoleID from dbo.UserRoles WHERE UserID = CONVERT(VARCHAR, @UserID))
                    OR EXISTS ( SELECT TOP 1 1 FROM dbo.Users WHERE UserID = CONVERT(VARCHAR, @UserID) AND IsSuperUser=1)
                )
        )
    )
ORDER BY
    Forum_Posts.PostID DESC

 

 
New Post
5/13/2009 1:41 PM
 

Following on with a "recent posts" query, how about one for "recent blog entries"? This only shows published items on public blogs, so privacy there is maintained too.

SELECT TOP 3
     Blog_Blogs.Title as 'BlogTitle'
    ,Blog_Entries.Title as 'EntryTitle'
    ,Blog_Entries.AddedDate as 'AddedDate'
    ,Blog_Entries.EntryID as 'EntryID'
FROM
    Blog_Entries
    INNER JOIN Blog_Blogs on Blog_Entries.BlogID = Blog_Blogs.BlogID
WHERE
    Blog_Blogs.PortalID = @PortalID
    AND Blog_Blogs.[Public] = '1'
    AND Blog_Entries.Published = '1'
ORDER BY
    Blog_Entries.EntryID DESC
 

 
New Post
5/13/2009 1:46 PM
 

And here's another... for upcoming events! This only shows approved events that aren't cancelled.

SELECT TOP 3
     [EventId]
    ,[EventDateBegin]
    ,[EventName]
FROM
    Events
WHERE
    Events.PortalID = @PortalID
    AND EventDateBegin >= getdate()
    AND Approved = 1
    AND Cancelled = 0
ORDER BY
    EventDateBegin

 

 
New Post
5/14/2009 2:46 AM
 

veldcath wrote

SELECT TOP 3
     Blog_Blogs.Title as 'BlogTitle'
    ,Blog_Entries.Title as 'EntryTitle'
    ,Blog_Entries.AddedDate as 'AddedDate'
    ,Blog_Entries.EntryID as 'EntryID'
FROM
    Blog_Entries
    INNER JOIN Blog_Blogs on Blog_Entries.BlogID = Blog_Blogs.BlogID
WHERE
    Blog_Blogs.PortalID = @PortalID
    AND Blog_Blogs.[Public] = '1'
    AND Blog_Entries.Published = '1'
ORDER BY
    Blog_Entries.EntryID DESC

Hi Veldcath,

you may prefer sorting entries by their added date instead fo their ID, like we do in our stored procedures, because bloggers can add entries with a different publish date.

Best regards,
Dario Rossa

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsMore refined "most recent posts" reportMore refined "most recent posts" report


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