Answers.Body: <p>You can build an array of the filtered results, then paginate that.</p>
  
  <pre><code>{% set entries = craft.entries().section('produkte').relatedTo(category) %}
  {% set filteredEntries = [] %}
  {% set existingtitle = [] %}
  {% for entry in entries %}
      {% if entry.title not in existingtitle %}
          {% set filteredEntries = filteredEntries|merge([entry]) %}
      {% endif %}
      {% set existingtitle = existingtitle|merge([entry.title]) %}
  {% endfor %}
  </code></pre>
  
  <p>Then modify this code to paginate array: <a href="https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a" rel="nofollow noreferrer">https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T07:09:40.123Z
Answers.Text: This gives me the error message: **TypeError: Argument 1 passed to craft\helpers\Template::paginateCriteria() must implement interface yii\db\QueryInterface, array given, ...**
Answers.UserDisplayName: TomS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T08:42:17.110Z
Answers.Text: My mistake, I thought you could paginate arrays. This tweet might be helpful to you: https://twitter.com/juban/status/1139207162159386625
Answers.UserDisplayName: dmatthams
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T08:45:19.383Z
Answers.Text: Even better, a gist: https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a have updated answer to reflect
Answers.UserDisplayName: dmatthams
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T12:33:13.057Z
Answers.Text: Thank you very much! I'll try this
Answers.UserDisplayName: TomS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-23T08:07:59.820Z
Answers.Text: I could solve it, with this code: https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a, thanks a lot to user3788089 for this information!
Answers.UserDisplayName: TomS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-21T11:00:23.827Z
Answers.LastActivityDate: 2019-08-22T08:44:59.927Z
Answers.LastEditDate: 2019-08-22T08:44:59.927Z
Answers.UserDisplayName: dmatthams
Body: <p>Some of my entries have the same entry.title. At the frontend, I would like to display these entries only once. This works with the following code:</p>
  
  <pre><code>{% set entries = craft.entries().section('produkte').relatedTo(category) %}
  {% set existingtitle = [] %}
   {% for entry in entries %}
    {% if entry.title not in existingtitle %}        
      {{ Display the Results }}
    {% endif %}
    {% set existingtitle = existingtitle|merge([entry.title]) %}
   {% endfor %}
  </code></pre>
  
  <p>My question is: How can I then paginate these results? For example 9 entries per page?
  If I paginate before the "if" condition gives me not the required result.
  Any help or tips are highly appreciated!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-09T18:00:01.580Z
Comments.Text: For issue 1 you could create another query on your second page using the offset function. So .limit(1).offer(8). This should get you the 9th entry. Also I would consider looping through your returned data and maybe reordering into a new array with the title as a key maybe.
Comments.UserDisplayName: Dean Sanderson
Tags: <entries><pagination><merge>
Title: Pagination and "if" condition
ThreadText: # Pagination and "if" condition
  
  (Asked by: username_0 on 2019-08-09)
  
  Some of my entries have the same entry.title. At the frontend, I would like to display these entries only once. This works with the following code:
  
  ```
  {% set entries = craft.entries().section('produkte').relatedTo(category) %}
  {% set existingtitle = [] %}
   {% for entry in entries %}
    {% if entry.title not in existingtitle %}        
      {{ Display the Results }}
    {% endif %}
    {% set existingtitle = existingtitle|merge([entry.title]) %}
   {% endfor %}
  
  ```
  
  My question is: How can I then paginate these results? For example 9 entries per page?
  If I paginate before the "if" condition gives me not the required result.
  Any help or tips are highly appreciated!
  
  **Tags:** entries, pagination, merge
  
  > **Comments:**
  > **username_1**: For issue 1 you could create another query on your second page using the offset function. So .limit(1).offer(8). This should get you the 9th entry. Also I would consider looping through your returned data and maybe reordering into a new array with the title as a key maybe.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-08-21. Score: 2 | Accepted answer
  
  You can build an array of the filtered results, then paginate that.
  
  ```
  {% set entries = craft.entries().section('produkte').relatedTo(category) %}
  {% set filteredEntries = [] %}
  {% set existingtitle = [] %}
  {% for entry in entries %}
      {% if entry.title not in existingtitle %}
          {% set filteredEntries = filteredEntries|merge([entry]) %}
      {% endif %}
      {% set existingtitle = existingtitle|merge([entry.title]) %}
  {% endfor %}
  
  ```
  
  Then modify this code to paginate array: <https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a>
  
  > **Comments:**
  > **username_0**: This gives me the error message: **TypeError: Argument 1 passed to craft\helpers\Template::paginateCriteria() must implement interface yii\db\QueryInterface, array given, ...**  
  > **username_2**: My mistake, I thought you could paginate arrays. This tweet might be helpful to you: https://twitter.com/juban/status/1139207162159386625  
  > **username_2**: Even better, a gist: https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a have updated answer to reflect  
  > **username_0**: Thank you very much! I'll try this  
  > **username_0**: I could solve it, with this code: https://gist.github.com/juban/a55781d49f2f68ec3ca47979bcaaa49a, thanks a lot to user3788089 for this information!  
  
  ---
  
  