Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Using macro in WHERE field View modes: 
User avatar
Member
Member
gliker-inorbital - 9/28/2011 1:30:51 PM
   
Using macro in WHERE field
Hi I'm trying to make this macro work:
{%if (cmscontext.currenttemplate.pagetemplatecodename == "deleteMe01") { "NewsTag = \'2\' " } else { "" }%}

Basically, I'm trying to insert value NewsTag = '2' into WHERE field if template code name is deleteMe01 but I'm getting syntax error. I tried bunch of different combinations but now I'm stuck.

Could someone help me with this?

Thanks


User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 9/28/2011 1:54:00 PM
   
RE:Using macro in WHERE field
Hello,

Could you please let me know the exact error message you are getting? At a first glance the macro seems to be written correctly.

Best regards,
Boris Pocatko

User avatar
Member
Member
gliker-inorbital - 9/28/2011 2:06:32 PM
   
RE:Using macro in WHERE field
Hi Boris,

Thanks for fast reply. I just found solution here:

http://devnet.kentico.com/Forums/f45/fp5/t17677/Custom-functions-in-Where-condition.aspx

CMS was replacing single quotes into double and I was getting error:

[DataConnection.ExecuteQuery]: Query: SELECT TOP 3 * FROM View_csmls_news_Joined WHERE ((((((SiteName = N'csmls') AND (Published = 1)) AND (DocumentCulture = N'en-CA')) AND (NodeLevel <= 3)) AND (NodeAliasPath LIKE N'/Special-Pages-(1)/News-and-Updates/%')) AND (NewsTag = ''2'')) : caused exception: Incorrect syntax near '2'.

User avatar
Certified Developer v7
Certified  Developer v7
Ankur - 10/12/2011 1:56:29 PM
   
RE:Using macro in WHERE field
Hi,

Please try removing quotes from Newstag value i.e 2 so it NewsTag = 2
{%if (cmscontext.currenttemplate.pagetemplatecodename == "deleteMe01") { "NewsTag = 2 " } else { "" }%}