If else In transformation with multiple Lines???

jack Ryder asked on July 11, 2014 05:41

Hello All, I want to Use webpart With transformation in if else condition using transformation. like this if(condition){ webpart1 } else{ webpart2 } can any one help me???

Recent Answers


Brenden Kehren answered on July 11, 2014 06:33

Are you asking to use a different transformation in a webpart based on what type of document is being rendered? If so you can use a macro

if(ClassName == "cms.menuitem"){return "something";)else{return "do something else";) %}
0 votesVote for this answer Mark as a Correct answer

jack Ryder answered on July 11, 2014 07:08 (last edited on July 14, 2014 11:51)

No, I want to render different webpart Layout based on document type field... I have create one document type called "Video". and define field type of video...and use dropdown as a from control for this field.Now add diiffernt document using this document type and now i want to use youtube web part based on selction of dropdown value in transformation lije as

if(dropdown value=="Youtube video")
{
use youtube video webpart(uc1:youtubevideo id="xyz" videourl="xyz")
}
else{
use kentico media preview webpart(cc1:preview id="xyz" defaultimage="abc.png" height:"scgsPX" width:"sdPX" )
}

documenttype field

Name of video Type of video(youtube or kentico video) url of video

0 votesVote for this answer Mark as a Correct answer

jack Ryder answered on July 11, 2014 07:11

I am using repeater For binding this document type data. and select transformation which i made in above question

0 votesVote for this answer Mark as a Correct answer

jack Ryder answered on July 11, 2014 07:13 (last edited on July 14, 2014 11:51)

Transformation: <%if (Convert.ToInt32(Eval("VideoType"))==1) { %>
<uc1:YouTubeVideo runat="server" ID="YouTubeVideo" CssClass="our_videos_img" VideoURL='<%# Eval("VideoURL") %>' Height="200" Width="200" /> <% } %> <% else { %> <%# Eval("VideoURL") %>' <a class="imageVideoBorder" href="<%# HTMLHelper.HTMLEncode (MediaLibraryFunctions.GetMediaFileDetailUrl(Eval("VideoURL"))) %>" title="<%# ResHelper.GetString(Convert.ToString(Eval("FileDescription"))) %>">

0 votesVote for this answer Mark as a Correct answer

jack Ryder answered on July 11, 2014 07:15

want to Render Web part based on document type particular field value for document which is created using this document type

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 12, 2014 18:48

I understand what you're trying to accomplish although I think you're transformation might be illegible and very hard to maintain. You might be better to create a YouTube doc type, a KenticoVideo doc type. Then use the Universal viewer webpart with a hierarchical transformation. This way you can set the transformation based on doc type. It's similar to what I initially posted but keeps the logic out of the transformation and therefor easier to understand and maintain.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.