PDA


View Full Version : [MOD] A slightly more helpful duplicate link message


StewardManscat
01-04-2005, 11:05 PM
I'm guessing that if somebody wanted to add a link, but it's already in the database, then we'd like to encourage them to comment or rate it.

Small hack in two parts.

1. In addlink.php find

$checkdupe = $DB_site->query("SELECT url FROM " . TABLE_PREFIX . "links WHERE url LIKE '%$linkdomain%' " . iif(!$dupe, "AND linkid != '$_POST[linkid]'") . " LIMIT 1");
while ($dupe = $DB_site->fetch_array($checkdupe))
{
if (strip_url($dupe['url']) == strip_url($_POST['url']))
{
$linkurl = htmlspecialchars($_POST['url']);
eval('$errors[] = "' . fetch_phrase('adv_links_duplicate', PHRASETYPEID_ERROR) . '";');
}
}



Replacw with:


$checkdupe = $DB_site->query("SELECT url,linkid,catid FROM " . TABLE_PREFIX . "links WHERE url LIKE '%$linkdomain%' " . iif(!$dupe, "AND linkid != '$_POST[linkid]'") . " LIMIT 1");
while ($dupe = $DB_site->fetch_array($checkdupe))
{
if (strip_url($dupe['url']) == strip_url($_POST['url']))
{
$linkdupecatid=$dupe['catid'];
$linkdupeid=$dupe['linkid'];
$linkurl = htmlspecialchars($_POST['url']);
eval('$errors[] = "' . fetch_phrase('adv_links_duplicate', PHRASETYPEID_ERROR) . '";');
}
}




2. Modify the phrase adv_links_duplicate to use $linkdupecatdid and $linkdupeid:


Slowpoke! Some other pig beat you to the punch.
<P>
Er, we mean: Sorry, but this url (<B>$linkurl</B>) is already in our database.<BR>No duplicates, thank you.<P>
Please add your rating or comments to the existing link [<A HREF=$vboptions[homeurl]/links/showlink.php?$session[sessionurl]do=showdetails&l=$linkdupeid&catid=$linkdupecatid><span class=smallfont>Do it now</span>]</A>



We've already made them type a bunch of stuff for nothing. I know most of my users won't bother at this point to search it out and add a comment or rating. This message gives them a direct link.

Brian
01-05-2005, 10:41 AM
Good idea. I may have to add something similar in the next version. :)

Polo
01-27-2005, 11:15 AM
This is cool and sure more efficient :) Thanks...