Answers.Body: <p>Short answer, it can't be done. I'm not sure why, but it's some sort of conflict with how <code>nav</code>, <code>children</code>, and <code>ifchildren</code> operates.</p>
  
  <p>The workaround is ugly (but it works). Just use two separate, but identical <code>if</code> statements... one before the <code>ifchildren</code>, and one after.</p>
  
  <pre><code>{% if comment.isFlagged() == false %}
      ...
  {% endif %}
  {% ifchildren %}
      ...
  {% endifchildren %}
  {% if comment.isFlagged() == false %}
      ...
  {% endif %}
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>If this solution doesn't work for you, I recommend looping over the <code>comments</code> array and removing all flagged comments <em>before</em> you run it through the <code>nav</code> loop.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T07:18:42.520Z
Answers.Text: This solution is not appropriate in my case because approved child comments of flagged (inappropriate) parent comment shows though the parent flagged (inappropriate) comment has been removed.
Answers.UserDisplayName: johirpro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T19:46:37.677Z
Answers.Text: You could potentially repeat the same conditional again _within_ the `ifchildren` tag. If that solution doesn't work for you, you might be out of luck.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-04T23:11:07.397Z
Answers.LastActivityDate: 2019-11-05T19:48:12.930Z
Answers.LastEditDate: 2019-11-05T19:48:12.930Z
Answers.UserDisplayName: Lindsey D
Body: <p>Craft CMS V2. <br>
  Comment Plugin: <a href="https://verbb.io/craft-plugins/comments" rel="nofollow noreferrer">verbb comment</a></p>
  
  <pre><code>&lt;ul&gt;
      {% nav comment in comments %}
         {% if comment.isFlagged() == false %}
            &lt;li&gt;
                {% include '_forms/templates/comment-' ~ comment.status %}
                {% include '_forms/templates/form' %}
  
              {% ifchildren %}
                  &lt;ul class="child"&gt;
                      {% children %}
                  &lt;/ul&gt;
              {% endifchildren %}
            &lt;/li&gt;
         {% endif %}
      {% endnav %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>The above code creates this error:</p>
  
  <pre><code>Unexpected "ifchildren" tag (expecting closing tag for the "if" tag)
  </code></pre>
  
  <p>So, How can I use <code>if/else</code> condition inside the <code>nav</code> tag to hide flagged comment including it's children.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-06T10:40:32.503Z
Comments.Text: Could something along those lines work - https://craftcms.stackexchange.com/questions/30688/show-only-children-relative-to-current-page/30695#30695 ?
Comments.UserDisplayName: Oli
Tags: <craft2><comments>
Title: 'If/else' statement inside 'nav' tag
ThreadText: # 'If/else' statement inside 'nav' tag
  
  (Asked by: username_0 on 2019-11-04)
  
  Craft CMS V2.   
  Comment Plugin: [verbb comment](https://verbb.io/craft-plugins/comments)
  
  ```
  <ul>
      {% nav comment in comments %}
         {% if comment.isFlagged() == false %}
            <li>
                {% include '_forms/templates/comment-' ~ comment.status %}
                {% include '_forms/templates/form' %}
  
              {% ifchildren %}
                  <ul class="child">
                      {% children %}
                  </ul>
              {% endifchildren %}
            </li>
         {% endif %}
      {% endnav %}
  </ul>
  
  ```
  
  The above code creates this error:
  
  ```
  Unexpected "ifchildren" tag (expecting closing tag for the "if" tag)
  
  ```
  
  So, How can I use `if/else` condition inside the `nav` tag to hide flagged comment including it's children.
  
  **Tags:** craft2, comments
  
  > **Comments:**
  > **username_1**: Could something along those lines work - https://craftcms.stackexchange.com/questions/30688/show-only-children-relative-to-current-page/30695#30695 ?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-11-04. Score: 1
  
  Short answer, it can't be done. I'm not sure why, but it's some sort of conflict with how `nav`, `children`, and `ifchildren` operates.
  
  The workaround is ugly (but it works). Just use two separate, but identical `if` statements... one before the `ifchildren`, and one after.
  
  ```
  {% if comment.isFlagged() == false %}
      ...
  {% endif %}
  {% ifchildren %}
      ...
  {% endifchildren %}
  {% if comment.isFlagged() == false %}
      ...
  {% endif %}
  
  ```
  
  **EDIT:**
  
  If this solution doesn't work for you, I recommend looping over the `comments` array and removing all flagged comments *before* you run it through the `nav` loop.
  
  > **Comments:**
  > **username_0**: This solution is not appropriate in my case because approved child comments of flagged (inappropriate) parent comment shows though the parent flagged (inappropriate) comment has been removed.  
  > **username_2**: You could potentially repeat the same conditional again _within_ the `ifchildren` tag. If that solution doesn't work for you, you might be out of luck.  
  
  ---
  
  