Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Query Users based on categories they've posted to View modes: 
User avatar
Member
Member
tj-norex - 7/10/2012 1:02:26 PM
   
Query Users based on categories they've posted to
I'm trying to get a list of all users that have published blog posts within a given category. I'm using the Users Viewer web part. I had no trouble pulling only users that had blog posts with the following query:

UserID IN(
SELECT NodeOwner FROM View_CONTENT_BlogPost_Joined WHERE
ClassName = 'CMS.BlogPost' AND
Published = 1 AND
NodeAliasPath LIKE '/Blog/%'
)
But I now want to only display users that have blog posts in a given category, I thought I could modify my query to the following:

UserID IN (
SELECT B.NodeOwner FROM View_CONTENT_BlogPost_Joined B
JOIN CMS_DocumentCategory C ON B.BlogPostID = C.DocumentID
WHERE
B.ClassName = 'CMS.BlogPost' AND
B.Published = 1 AND
B.NodeAliasPath LIKE '/Blog/%' AND
C.CategoryID = '{%categoryid%}'
)
However that is not returning any results. It's hard to pin down exactly what I'm missing because I don't get any SQL errors. Any thoughts? Am I looking at the totally wrong table? Thanks!

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/10/2012 5:20:19 PM
   
RE:Query Users based on categories they've posted to
Hi,

The issue is that B.BlogPostID = C.DocumentID are not the same values. It should be B.DocumentID = C.DocumentID

ClassName = 'CMS.BlogPost' -> you can remove this condition, in the view are only blog posts.

Best regards,
Ivana Tomanickova