Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > String concatenation in transformation View modes: 
User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/8/2013 5:44:07 AM
   
String concatenation in transformation
Hi,

I have this string in repeater which will be rendered using macro expressions

<%# ((DataItemIndex % 4 == 0 || DataItemIndex % 4 == 1) ? "<div class='large-6 small-6 columns topicTxt'><div class='article-block' onclick='location.href='"<%# GetDocumentUrl() %>'" style='cursor:pointer'><em class='author'><%# Eval("Author") %></em><h4 class='title'><%# Eval("Headline") %></h4><div class='topicFoot'><span class='topicIcon <%# Eval("Specie") %>'></span><span class='topicPlay'></span><span class='topicLink'></span></div></div></div>" : "<div class='large-6 small-6 columns topicBg' style='background-image: url("/CMSPages/GetFile.aspx?guid=<%# Eval("Image") %>")'><span class='topicArrow'></span></div>" ) %>


Can someone help me with syntax so that it can render correctly?

User avatar
Kentico Legend
Kentico Legend
Accepted solutionAccepted solution
Brenden Kehren - 8/8/2013 6:43:07 AM
   
RE:String concatenation in transformation
This should get you working.
<%# ((DataItemIndex % 4 == 0 || DataItemIndex % 4 == 1) ? "<div class='large-6 small-6 columns topicTxt'><div class='article-block' onclick='location.href='" + GetDocumentUrl() + "' style='cursor:pointer'><em class='author'>" + Eval("Author") + "</em><h4 class='title'>" + Eval("Headline") + "</h4>" : "<div class='topicFoot'><span class='topicIcon " + Eval("Specie") + "'></span><span class='topicPlay'></span><span class='topicLink'></span></div>") %>
Remember if you are already inside a code block (<%# %>), you don't need to put another code block around an Eval("Name") again, I think that is where you're problem came from. Easiest thing to do is create them in Visual Studio to help get the syntax part correct, then paste into the text editor on the site and see how it looks.

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/8/2013 11:24:20 AM
   
RE:String concatenation in transformation
Thanks FroggEye,

I realized this later. Thanks for pointing me to right direction

Regards,
Chetan