Not able to give condition in web part container for widget

Ranapratap Bhopale asked on October 24, 2018 09:35

{% if (!string.IsNullOrEmpty({%TileURL%})){ %}

{%TileHeading%}

{% }else{ %}

--NOT RESOLVING MACRO {% if (!string.IsNullOrEmpty({%TileURL%})){ %}

how to fix this? I have to give condition in web part container for widget and TileURL is one of field in widget.

Correct Answer

Dragoljub Ilic answered on October 24, 2018 10:35

Hi,

You should check event log for more info about error that occurs when you reload the page. That could be good start. From this point, I see that you used nested macros. It should be like this:

{% if (!string.IsNullOrEmpty(TileURL)){ %}

Best regards, Dragoljub

0 votesVote for this answer Unmark Correct answer

Recent Answers


Ranapratap Bhopale answered on October 24, 2018 11:21 (last edited on October 24, 2018 11:54)

@Dragoljub Ilic it is working,Thanks

0 votesVote for this answer Mark as a Correct answer

Dragoljub Ilic answered on October 24, 2018 11:58 (last edited on December 10, 2019 02:31)

Is there any errors occurs in event log? Which version of Kentico you are using? I tried this code bellow and works fine in widget container template.

 {% if (!string.IsNullOrEmpty(CustomFieldName)){ %}
 <h1>Test: {% CustomFieldName %}</h1>
{% } else { %}
  <h1>Some dummy text</h1>
{% } |(identity)GlobalAdministrator%}

You should not wrap [Web part] placeholder in your container with macro.

0 votesVote for this answer Mark as a Correct answer

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