Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Macros in transformations View modes: 
User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 7/30/2013 10:27:11 AM
   
Macros in transformations
Hi All,

I am trying to using macros expression inside my transformation as referred by this article

http://devnet.kentico.com/Knowledge-Base/Content-Management/Using-special-item-data-in-transformation.aspx

Few questions and doubts:-

1. Will it work for custom transformation?

My transformation generating some strange text while rendering template.

Following is my transformation code.

{%# if (DataItemIndex mod 2 == 0) {"<div class=\"large-12 columns topicHead\">"<%# Eval("Specie")%>"</div>"}%}
<div class="large-6 small-12 columns topic">
<div class="large-6 small-6 columns">
<div class="article-block">
<em class="author"><%# Eval("Author") %></em>
<h4 class="title"><%# Eval("Headline") %></h4>
<div class="topicFoot">
<span class="topicIcon horse"></span>
<span class="topicPlay"></span>
<span class="topicLink"></span>
</div>
</div>
</div>
<div class="large-6 small-6 columns topicBg <%# Eval("Specie") %>1"><span class="topicArrow"></span></div>
</div>

Any help will be appreciated!!

User avatar
Member
Member
kentico_sandroj - 7/30/2013 12:47:03 PM
   
RE:Macros in transformations
Hello,

The transformation methods should work for your custom transformation once implemented correctly. Would you mind explaining what is the goal here? Also, what is the strange text that you get on render?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/30/2013 8:24:25 PM
   
RE:Macros in transformations
You don't need to use a macro for that, you can use simple C# code in your transformation like so
<%# ((DataItemIndex % 3 == 0) ? "<div class=\"row\"><div class=\"same-height\"> " : "" ) %>
This checks and says if its the first one of 3, place the <div> tags in front of the data item otherwise, just put an empty string.

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 7/31/2013 1:34:22 AM
   
RE:Macros in transformations
Thanks a ton FroggEye. You are a savior :)