Anatoliy
Well-known member
What would be the way to find and list all threads with duplicated titles?
So far I have a repository that grabs all the threads and then in template it checks for duplicates. The good thing it checks only 20 x all threads, not all treads x all thread. The bad thing - it lists all the threads regardless if it has duplicates or not.
Probably there is a better way to find duplicates and to list duplicates only? Please advise.
So far I have a repository that grabs all the threads and then in template it checks for duplicates. The good thing it checks only 20 x all threads, not all treads x all thread. The bad thing - it lists all the threads regardless if it has duplicates or not.
Code:
<xf:title>Duplicated Thread Titles</xf:title>
<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}" link="duplicated-thread-titles" wrapperclass="block" />
<xf:foreach loop="$data" value="$dat">
<div class="block" style="margin-bottom: 3px">
<div class="block-container">
<div style="padding:10px;">
<a href="{{ link_type('public', 'threads', $dat) }}" target="new"><h3 style="margin:0">{{$dat.title}}</h3></a>
<xf:if contentcheck="true">
<xf:contentcheck>
<xf:foreach loop="$data" value="$otherThread">
<xf:if is="$dat.thread_id != $otherThread.thread_id && $dat.title|to_lower == $otherThread.title|to_lower">
<a href="{{ link_type('public', 'threads', $otherThread) }}" target="new" style="color:#b71c1c"><h3 style="margin:0">{{$otherThread.title}}</h3></a>
</xf:if>
</xf:foreach>
</xf:contentcheck>
</xf:if>
</div>
</div>
</div>
</xf:foreach>
<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}" link="duplicated-thread-titles" wrapperclass="block" />
Probably there is a better way to find duplicates and to list duplicates only? Please advise.