Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2017-07-25 18:43:23

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Search result without duplicates

Hi,

I have some photos that are present in several albums. Is it possible during a search, to tell Backlight not to display duplicates?


Thanks
Nico

Offline

#2 2017-07-25 19:46:27

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Search result without duplicates

The search doesn't filter for duplicates. It simply checks for hits in each albums and displays the results.


Matt

The Turning Gate, http://theturninggate.net

Offline

#3 2017-07-25 19:55:35

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Re: Search result without duplicates

Ah OK, I thought there would be a way to tweak a code of the following style:

$sql = "SELECT distinct filename from my_table";
$res = mysql_query($sql);

while($row = mysql_fetch_array($res))
{
    echo $row['filename'].'<br /><br />';
}

Thanks
Nico

Offline

#4 2017-08-10 20:55:52

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Search result without duplicates

This is something we could add via a Publisher setting (e.g. Remove Duplicate Photos in Search).  I've added it to our feature list for possible future updates.

Offline

#5 2017-08-10 21:47:10

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Re: Search result without duplicates

Whao Cool !
Thanks Ben

Last edited by Nico3939 (2017-08-10 21:47:20)

Offline

#6 2018-02-17 09:47:27

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Search result without duplicates

I've added this into the next major version of Backlight.

Offline

#7 2018-02-17 09:51:49

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Re: Search result without duplicates

Whaoo! Very cool ! Thanks very much Ben!!!

Offline

#8 2018-02-17 19:03:54

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Search result without duplicates

No worries.  Emphasis on next *major* version, which will be a paid upgrade.

If you feel inclined to edit Backlight, the same result can be achieved by editing the file backlight/publisher/application/models/SearchResult.php, changing this:

	function getFilteredPhotoResults()
	{
		$filtered = array();
		
		foreach ($this->photoResults as $photo) {
			if ($photo->filter($this->required, $this->omitted)) {
				$filtered[] = $photo;
			}
		}

		return $filtered;
	}

To this:

	function getFilteredPhotoResults() 
	{
		$filenameLookup = array();
		$removeDuplicates = true;

		$filtered = array();
		
		foreach ($this->photoResults as $photo) {
			if ($removeDuplicates) {
				if (isset($filenameLookup[$photo->getFilename()])) {
					continue;
				} else {
					$filenameLookup[$photo->getFilename()] = true;
				}
			}

			if ($photo->filter($this->required, $this->omitted)) {
				$filtered[] = $photo;
			}
		}

		return $filtered;
	}

This functionality will be configurable in the next major version of Backlight.

Offline

#9 2018-03-28 16:29:14

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Re: Search result without duplicates

Hi,

I just try the code but I have the following error:

"Something went wrong

Unexpected error: syntax error, unexpected '$filtered' (T_VARIABLE) in SearchResult.php on line 182

Please report error at http://community.theturninggate.net"

Nico

Offline

#10 2018-03-28 21:06:16

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Search result without duplicates

what’s on line 182?
Chances are the syntax error is near that.

You may not have copied all the code Ben posted. Or perhaps you opened the file indicated in a word processor and inherited its formatting?

Make sure you’re replacing code and not just adding the modified code.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#11 2018-04-13 02:34:15

Nico3939
Member
From: France
Registered: 2016-10-05
Posts: 235
Website

Re: Search result without duplicates

Ok I find the problem.

In your code there is a punctuation symbol (;) forgotten at the end of the next line:

$removeDuplicates = true

Replace by:

$removeDuplicates = true;

and it work

Thanks very much
Nico

Offline

Board footer

Powered by FluxBB