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.
You are not logged in.
Pages: 1
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
The search doesn't filter for duplicates. It simply checks for hits in each albums and displays the results.
Offline
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
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
Whao Cool !
Thanks Ben
Last edited by Nico3939 (2017-08-10 21:47:20)
Offline
I've added this into the next major version of Backlight.
Offline
Whaoo! Very cool ! Thanks very much Ben!!!
Offline
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
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
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
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
Pages: 1