If statement in static html web part

Harika Polavaram asked on July 11, 2014 19:31

Hi,

I am trying to add if statement in static html web part. I have a image fields, I wanted to display that only if the value is present, if it is empty I wanted to display blank. All the examples so far are inside repeater/transforamtion.

Can we do that in a static html web part too?

Recent Answers


Adam Gitin answered on July 13, 2014 07:03

Hi,

You can use the webparts VISIBLE property.

Add an IF macro.

{%
 if(yourValueIsTrue){
    return true;
 }else{
    return false;
 }

%}

Hope this helps,

Adam @4Hlton

0 votesVote for this answer Mark as a Correct answer

Harika Polavaram answered on July 14, 2014 16:40

Hi Adam,

Thank you for the reply. I am trying to apply this inside HTMl part. I am thinking that the above code snippet you posted is for the whole web part. I just wanted to apply the If condition around the Image tag.


{%Title%}

      <div class="large-5 medium-5 column">
   <img class="border" src="{%Image%}" />
      </div>
      <div class="large-7 medium-7 column">
        {%Content%}
      </div>

      ********************************************
0 votesVote for this answer Mark as a Correct answer

Adam Gitin answered on July 15, 2014 09:53

Hi,

You try something like this:

<div class="large-5 medium-5 column">
{%
 if(yourValueIsTrue){
%}
 <img class="border" src="{%Image%}" />
 {%}%}

      </div>
      <div class="large-7 medium-7 column">
        {%Content%}
      </div>

Hope this works for you,

Adam @4Hlton

0 votesVote for this answer Mark as a Correct answer

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