Answers.Body: <p>It's probably your second-from-last line:</p>
  
  <pre><code>{% endfor % }
  </code></pre>
  
  <p>should be:</p>
  
  <pre><code>{% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T13:06:34.787Z
Answers.Text: Of course, you're right. Thank you very much!
Answers.UserDisplayName: MISC
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T12:31:09.263Z
Answers.LastActivityDate: 2016-08-05T12:31:09.263Z
Answers.UserDisplayName: Mike Pepper
Body: <p>I have a comment section with comments and subcomments. A comment relates directly to the blog post while a subcomment relates to a comment.</p>
  
  <p>Now, I have the following problem on the entry page: Showing the comments only is not a problem:</p>
  
  <pre><code>{% for comment in craft.entries({
      section: comments,
      relatedTo: { targetElement: entry, field: "relentry" },
      order:     "sortOrder",
      limit:     null
  }) %}
      &lt;p&gt;X&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>But when I insert the subcomments, I get the error message <code>Unexpected "}"</code>:</p>
  
  <pre><code>{% for comment in craft.entries({
      section: comments,
      relatedTo: { targetElement: entry, field: "relentry" },
      order:     "sortOrder",
      limit:     null
  }) %}
      &lt;p&gt;X&lt;/p&gt;
      {% for subcomment in craft.entries({
          section: comments,
          relatedTo: { targetElement: comment, field: "relentry" },
          order:     "sortOrder",
          limit:     null
      }) %}
          &lt;p&gt;Y&lt;/p&gt;
      {% endfor % }
  {% endfor %}
  </code></pre>
  
  <p>Thank you very much for your help!</p>
  
Tags: <forloop><relatedto>
Title: Error in case of nested for loops
ThreadText: # Error in case of nested for loops
  
  (Asked by: username_0 on 2016-08-05)
  
  I have a comment section with comments and subcomments. A comment relates directly to the blog post while a subcomment relates to a comment.
  
  Now, I have the following problem on the entry page: Showing the comments only is not a problem:
  
  ```
  {% for comment in craft.entries({
      section: comments,
      relatedTo: { targetElement: entry, field: "relentry" },
      order:     "sortOrder",
      limit:     null
  }) %}
      <p>X</p>
  {% endfor %}
  
  ```
  
  But when I insert the subcomments, I get the error message `Unexpected "}"`:
  
  ```
  {% for comment in craft.entries({
      section: comments,
      relatedTo: { targetElement: entry, field: "relentry" },
      order:     "sortOrder",
      limit:     null
  }) %}
      <p>X</p>
      {% for subcomment in craft.entries({
          section: comments,
          relatedTo: { targetElement: comment, field: "relentry" },
          order:     "sortOrder",
          limit:     null
      }) %}
          <p>Y</p>
      {% endfor % }
  {% endfor %}
  
  ```
  
  Thank you very much for your help!
  
  **Tags:** forloop, relatedto
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-05. Score: 2 | Accepted answer
  
  It's probably your second-from-last line:
  
  ```
  {% endfor % }
  
  ```
  
  should be:
  
  ```
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Of course, you're right. Thank you very much!  
  
  ---
  
  