Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Related Blog Posts View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 9/12/2013 10:39:15 PM
   
Related Blog Posts
I want to get a list of TOPN blog posts with the tag(s) contained in the current blog post. I haven't been able to find a good way to do with with a query/repeater combination.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/12/2013 10:55:44 PM
   
RE:Related Blog Posts
Hi,

Have you tried using a WHERE condition similar that is used together with the tag cloud web part? Using this condition the repeater is selecting the documents. I believe that you just need to add it to the query that is selecting the top documents you want.

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 9/13/2013 1:11:50 AM
   
RE:Related Blog Posts
I did look at that although I didn't read what each line was for until you pointed it out, so thank you for that as I ended up using a version of the last line in that query.

I ended up using this in my item transformation
<script runat="server">
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
rptRelated.WhereCondition = "DocumentID in (SELECT DISTINCT DocumentID FROM CMS_DocumentTag WHERE TagID IN (SELECT TagID FROM CMS_DocumentTag WHERE DocumentID = " + ValidationHelper.GetInteger(Eval("DocumentID"), 0).ToString() + ") AND DocumentID <> " + ValidationHelper.GetInteger(Eval("DocumentID"), 0).ToString() + ")";
rptRelated.ReloadData(true);
}
</script>
along with a repeater in my transformation.