Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > WHERE clause macro syntax question. View modes: 
User avatar
Member
Member
vcarter - 11/11/2013 11:48:04 AM
   
WHERE clause macro syntax question.
I have created a custom filter control for my news section. It generates a where clause for a custom query. My news is structured as follows:

NewsRoom
- 2013
- News Item
-2012
- News Item

Newsroom, 2013, and 2012 all use the same template and filter. I would like to add an additional condition to the where clause generated by the filter for each of the "year" sections.

Is this possible?

User avatar
Member
Member
vcarter - 11/11/2013 12:26:33 PM
   
RE:WHERE clause macro syntax question.
Just figured this out:
 <script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string curNode = CMS.CMSHelper.CMSContext.CurrentPageInfo.NodeID.ToString();
string where = this.srcElem.WhereCondition;

if (curNode != "[All News Node ID]"){
if (where != ""){
where = where + "AND view_custom_news_joined.NodeParentID = " + curNode;
}else{
where = "view_custom_news_joined.NodeParentID = " + curNode;
}
}


this.srcElem.WhereCondition = where;
}
</script>

Added this to the Layout Tab of my QueryDataSource web part. This preserves my filter control generated where clause and appends the parent node conditional as required.

Hope this helps someone later on.