Hi all,
I have put together a very simple custom macro - utilising the ResolveCustomMacro.cs file in app_code/global/cms/cmscustom.cs
Its for use in the Where field in a datalist
here is the code:
public static string ResolveCustomMacro(MacroResolver sender, string expression, out bool match)
{
match = false;
string result = "";
// Add your custom macro evaluation
switch (expression.ToLower())
{
case "checkmusiccategory":
match = true;
string cat = QueryHelper.GetString("cat", "");
if (cat != "")
{
HttpContext.Current.Response.Write(cat);
result = " Category = '" + cat + "' ";
HttpContext.Current.Response.Write("<br />" + result);
}
break;
}
return result;
}
Now, if ?cat doesn't exists in the Qstring then nothing is returned = datalist shows all documents which is what i want.
however, if there is a ?cat then i get the following error:
[DataConnection.ExecuteQuery]: Query: SELECT * FROM View_custom_YouTube_Joined WHERE (((((SiteName = N'DownsSyndromeThailand') AND (Published = 1)) AND (DocumentCulture = N'en-US')) AND (NodeAliasPath LIKE N'/Music/Music-Library/%')) AND ( Category = ''Kids'' )) ORDER BY documentcreatedwhen DESC : caused exception: Incorrect syntax near 'Kids'.
Notice the additional ' in the where clause around Kids
whats causing this??
Darren