PDA

View Full Version : Get link by domain - getLinkByDomain()


add
05-15-2007, 06:45 PM
Hello again,

I need to output link's info on domain (want have urls like http://example.com/page/domain.com) so I created function getLinkByDomain() changing this line ($sql .= "WHERE t1.`id` = '{$aLink}' ";) of original function function getLinkById() to ($sql .= "WHERE t1.`domain` = '$linkhost' ";)

function getLinkByDomain($aLink)
{
$linkparse = parse_url($aLink);
$linkhost = $linkparse['host'];
$sql = "SELECT t1.*, `t1`.`comments_active` `comments`, ";
$sql .= "t6.`path`, t6.`title` category_title, t6.`id` id_category ";
$sql .= "FROM `".$this->mTable."` t1 ";
$sql .= "LEFT JOIN `".$this->mPrefix."link_categories` t5 ";
$sql .= "ON t5.`id_link` = t1.`id` ";
$sql .= "AND t5.`crossed` = '0' ";
$sql .= "LEFT JOIN `".$this->mPrefix."categories` t6 ";
$sql .= "ON t5.`id_category` = t6.`id` ";
$sql .= "WHERE t1.`domain` = '$linkhost' ";
$sql .= "AND t6.`status` = 'active' ";
$sql .= "GROUP BY t1.`id`";

return $this->getRow($sql);
}

and then changing original code /** get current link info **/ in view-link.php to:

/** get current link info **/
if ($_GET['domain']) {
$link =& $gDirDb->getLinkByDomain($_GET['domain']);
} elseif ($_GET['id']) {
$link =& $gDirDb->getLinkById($_GET['id']);
}


Now when i'm accessing the page http://localhost/directory/view-link.php?cat=&title=&domain=http://www.example.com I recieve this error: Error: Requested URL not found (404)

I believe that the error stands in path, because if I print $link variable it gives me correct info about link in array ($link) but template still shows errors instead of page with link information.

Can you help me to find what i'm missing?

Thanks again,
Alex

add
05-15-2007, 11:06 PM
I figured it out by myself,
just need to change from GET variables to variables from Array $link in view-link.php:

lc.id_link = '".$link['id']."'
AND
c.`path` = '".$link['category_title']."'");

Thanks anyway!
Best regards!

Sergey Ten
05-16-2007, 04:48 AM
Good Alex :good: