bdeeney
12-13-2006, 09:30 PM
Hi
Is it possible to have featured links appear above paid sponsor links on the link pages. I have enabled sponsored links to show at top and also have enabled featured links to show at top. At the moment sponsored links are displaying above featured links.
Brian
Dave Baker
12-13-2006, 10:53 PM
Please make a backup copy of your file classes/Dir.php
***Open classes/Dir.php and find function***
function getLinksByCategory($aCategory = 0, $aStart = 0, $aLimit = 0, $aFeatured = TRUE, $aSponsored = FALSE, $aEditor = '')
*** In this function find two pieces of a code ***
if ($aSponsored)
{
$sql .= "(SELECT t1.*, COUNT(DISTINCTROW t2.id) comments, COUNT(DISTINCTROW t3.id) clicks, AVG(t7.`vote_value`) rating, ";
$sql .= "t5.`path` path, t31.`crossed` crossed, '1' `sponsored`, '0' `featured` ";
$sql .= ($aEditor) ? ", IF ((t16.`id_editor` IS NULL) OR (t16.`id_editor` = '0'), '0', '1') id_editor_edit " : ", '0' id_editor_edit ";
$sql .= "FROM `{$this->mPrefix}link_categories` t31 ";
$sql .= "LEFT JOIN `{$this->mPrefix}links` t1 ";
$sql .= "ON t1.`id` = t31.`id_link` ";
$sql .= "RIGHT JOIN `{$this->mPrefix}sponsored` t41 ";
$sql .= "ON t41.`id_link` = t1.`id` ";
$sql .= "LEFT JOIN `{$this->mPrefix}featured` t4 ";
$sql .= "ON t4.`id_link` = t1.`id` ";
$sql .= "LEFT JOIN `{$this->mPrefix}link_comments` t2 ";
$sql .= "ON t41.`id_link` = t2.`id_link` ";
$sql .= "AND t2.`status` = 'active' ";
$sql .= "LEFT JOIN `{$this->mPrefix}link_clicks` t3 ";
$sql .= "ON t41.`id_link` = t3.`id_link` ";
$sql .= "LEFT JOIN `{$this->mPrefix}categories` t5 ";
$sql .= "ON t5.`id` = t31.`id_category` ";
if ($aEditor)
{
$sql .= "LEFT JOIN `{$this->mPrefix}categories_editors` t16 ";
$sql .= "ON t16.`id_editor` = '{$aEditor}' ";
}
$sql .= "LEFT JOIN `{$this->mPrefix}votes` t7 ";
$sql .= "ON t1.`id` = t7.`id_link` ";
$sql .= "WHERE t31.`id_category` = '{$aCategory}' ";
$sql .= "AND t1.`status` = 'active' ";
$sql .= "GROUP BY t1.`id` ";
$order = ($gDirConfig['links_sorting'] == 'alphabetic') ? 'title' : $gDirConfig['links_sorting'];
$order_type = ($gDirConfig['links_sorting_type'] == 'ascending') ? 'ASC' : 'DESC';
$sql .= "ORDER BY `{$order}` {$order_type} LIMIT 0, 10000) ";
$sql .= "UNION ALL ";
}
AND
if ($aFeatured)
{
$sql .= "(SELECT t1.*, COUNT(DISTINCTROW t2.id) comments, COUNT(DISTINCTROW t3.id) clicks, AVG(t7.`vote_value`) rating, ";
$sql .= "t5.`path` path, t31.`crossed` crossed, '0' `sponsored`, '1' `featured` ";
$sql .= ($aEditor) ? ", IF ((t16.`id_editor` IS NULL) OR (t16.`id_editor` = '0'), '0', '1') id_editor_edit " : ", '0' id_editor_edit ";
$sql .= "FROM `{$this->mPrefix}link_categories` t31 ";
$sql .= "LEFT JOIN `{$this->mPrefix}links` t1 ";
$sql .= "ON t1.`id` = t31.`id_link` ";
$sql .= "RIGHT JOIN `{$this->mPrefix}featured` t4 ";
$sql .= "ON t4.`id_link` = t1.`id` ";
$sql .= "LEFT JOIN `{$this->mPrefix}sponsored` t41 ";
$sql .= "ON t41.`id_link` = t1.`id` ";
$sql .= "LEFT JOIN `{$this->mPrefix}link_comments` t2 ";
$sql .= "ON t4.`id_link` = t2.`id_link` ";
$sql .= "AND t2.`status` = 'active' ";
$sql .= "LEFT JOIN `{$this->mPrefix}link_clicks` t3 ";
$sql .= "ON t4.`id_link` = t3.`id_link` ";
$sql .= "LEFT JOIN `{$this->mPrefix}categories` t5 ";
$sql .= "ON t5.`id` = t31.`id_category` ";
if ($aEditor)
{
$sql .= "LEFT JOIN `{$this->mPrefix}categories_editors` t16 ";
$sql .= "ON t16.`id_editor` = '{$aEditor}' ";
}
$sql .= "LEFT JOIN `{$this->mPrefix}votes` t7 ";
$sql .= "ON t1.`id` = t7.`id_link` ";
$sql .= "WHERE t31.`id_category` = '{$aCategory}' ";
$sql .= "AND t1.`status` = 'active' ";
$sql .= "GROUP BY t1.`id` ";
$order = ($gDirConfig['links_sorting'] == 'alphabetic') ? 'title' : $gDirConfig['links_sorting'];
$order_type = ($gDirConfig['links_sorting_type'] == 'ascending') ? 'ASC' : 'DESC';
$sql .= "ORDER BY `{$order}` {$order_type} LIMIT 0, 10000) ";
$sql .= "UNION ALL ";
}
*** Change their places(In the place of first second, in the place second first).***
***Save file***
bdeeney
12-13-2006, 11:44 PM
Thanks for that Dave - worked fine
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.