How can I right this script into a repater transformation

Dcode warner asked on February 28, 2017 01:38

This is a script that works well inside a static HTML web part. How can I write the same script but inside a repeater transformation?

{% if(showPhone) { %}
555-555-5555 {% } #%}

Recent Answers


Peter Mogilnitski answered on February 28, 2017 04:25 (last edited on February 28, 2017 04:44)

You don't have to use ACSX, you can perfectly use Text/XML transformation with your repeater, so your dont have to chanage your macro and it will work.

It possible with ACSX but conditional statements are kind of awkward: <%# IfTrue(CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("showPhone"),"555-555-5555")%>

There is a couple posts on this topic: post1, post2, but I would just use Text/XML.

2 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 28, 2017 17:35

@Peter M Thanks. How can I write this one: {% if(showPhone) { %} if true else do something else

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on February 28, 2017 18:37

You should be able to use:

{% if(showPhone) { return '555-555-5555'; } else { return 'NA'; } %}

or

{% if (showPhone) { %}555-555-555{% }else{ %}NA{% }%}

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 28, 2017 18:56

I tired both but the result 'na' does not show if switch to true. True isn't working. I have this script in the HTML envelope. Does it matter?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 28, 2017 21:41 (last edited on February 28, 2017 21:47)

You can have it in HTML Envelope - no issues.

{%if (showPhone) {"555-555-5555"} else { "NA"} @%} or {% showPhone ? "555-555-5555" : "NA" @%}

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 28, 2017 23:55

I need to rewrite the code since it's not working the way it should. How can I write this in a repeater- using a check box. Is the below correct?

<%# IfTrue(Eval("showFull") =="true" , "Empty","Full")%>

0 votesVote for this answer Mark as a Correct answer

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