phplinkdirectory: How to increase number of featured links in main page?
09-06-2008, 10:18 AM
|
phplinkdirectory: How to increase number of featured links in main page?
|
Posts: 132
|
As you can see, the number of featured links displayed in the main page of my directory www.in4city.com is only 3. How can I increase them to may be 5 or 6? Which file should I edit? 
|
|
|
|
09-06-2008, 11:12 AM
|
Re: phplinkdirectory: How to increase number of featured links in main page?
|
Posts: 3,591
Name: Praveen
Location: Chennai, India
|
depending on which version you are running
search in index.php for a code similar to this
Code:
$last5feat = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE STATUS = 2 AND FEATURED = 1 ORDER BY ID DESC LIMIT 0,3");
change the 0,3 to 0,5 or 6
remember this code may be different depending on your version.
best bet would be the phplinkdirectory forums.
|
|
|
|
09-07-2008, 06:10 AM
|
Re: phplinkdirectory: How to increase number of featured links in main page?
|
Posts: 132
|
Below is my index.php file, but I cant find the codes you mentioned, can anyone help?
Code:
require_once 'init.php';
define('DIR_LPP', 20);
$sort_cols = array ( 'P' => 'PAGERANK', 'H' => 'HITS', 'A' => 'TITLE');
$sort_ord = array ( 'P' => 'DESC' , 'H' => 'DESC', 'A' => 'ASC');
// Paging 1
$page = (!empty ($_REQUEST['p']) && preg_match ('`^[\d]+$`', $_REQUEST['p']) ? intval ($_REQUEST['p']) : 1);;
if ($page != 1)
{
$min = PAGER_LPP * $page - (PAGER_LPP);
$max = PAGER_LPP * $page;
}
else
{
$min = 0;
$max = PAGER_LPP;
}
$limit = " LIMIT {$min}," . PAGER_LPP;
// End Paging 1
$getSort = (!empty ($_REQUEST['s']) ? trim ($_REQUEST['s']) : (!empty ($URLvariables['s']) ? $URLvariables['s'] : ''));
if (array_key_exists ($getSort, $sort_cols))
{
$sort = $getSort;
}
else
{
$sort = DEFAULT_SORT;
}
if ((ENABLE_PAGERANK != 1 || SHOW_PAGERANK != 1) && $sort == 'P')
$sort = 'H';
$tpl->assign('sort', $sort);
$path = array();
$path[] = array ('ID' => '0', 'TITLE' => _L(SITE_NAME), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => SITE_DESC);
if (FTR_ENABLE)
{
$feat_where = "AND (`FEATURED` = '0')";
}
$expire_where = "AND (`EXPIRY_DATE` >= ".$db->DBDate(time())." OR `EXPIRY_DATE` IS NULL)";
$available_options = array ('d' => _L('Latest Links'), 'h' => _L('Top Hits'));
if (!empty ($_REQUEST['p']) && array_key_exists ($_REQUEST['p'], $available_options))
{
switch ($_REQUEST['p'])
{
case 'd':
$links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' {$expire_where} ORDER BY `DATE_ADDED` DESC LIMIT 0, ".LINKS_TOP);
$path[] = array ('ID' => '0', 'TITLE' => _L('Latest Links'), 'TITLE_URL' => '', 'DESCRIPTION' => '');
break;
case 'h':
default :
$links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' {$expire_where} ORDER BY `HITS` DESC LIMIT 0, ".LINKS_TOP);
$path[] = array ('ID' => '0', 'TITLE' => _L('Top Hits'), 'TITLE_URL' => '', 'DESCRIPTION' => '');
break;
}
$tpl->assign('p', $_REQUEST['p']);
}
elseif (isset ($_REQUEST['q']) && !empty ($_REQUEST['q']) && strlen (trim ($_REQUEST['q'])) > 2)
{
$q = $db->qstr('%'.preg_replace('`\s+`','%', trim ($_REQUEST['q'])).'%');
if (FTR_ENABLE)
{
$feat_links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND (`URL` LIKE {$q} OR `TITLE` LIKE {$q} OR `DESCRIPTION` LIKE {$q}) AND `FEATURED` = '1' {$expire_where} ORDER BY `EXPIRY_DATE` DESC");
$tpl->assign('feat_links', $feat_links);
}
$links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND (`URL` LIKE {$q} OR `TITLE` LIKE {$q} OR `DESCRIPTION` LIKE {$q}) {$feat_where} {$expire_where} ORDER BY {$sort_cols[$sort]} {$sort_ord[$sort]}");
$categs = array();
$path[] = array ('ID' => '0', 'TITLE' => _L('Search Results'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Search results for: ').$_REQUEST['q']);
$tpl->assign('qu', rawurlencode (trim ($_REQUEST['q'])));
}
else
{
$id = get_category();
if (!$tpl->is_cached('main.tpl', $id))
{
$path = get_path($id);
if (FTR_ENABLE)
{
$feat_links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($id)." AND `FEATURED` = 1 {$expire_where} ORDER BY `EXPIRY_DATE` DESC");
$tpl->assign('feat_links', $feat_links);
}
// Paging 3
$count = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($id)." {$feat_where} {$expire_where}");
// End Paging 3
$links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($id)." {$feat_where} {$expire_where} ORDER BY `{$sort_cols[$sort]}` {$sort_ord[$sort]} {$limit}");
$rs = $db->Execute("SELECT * FROM `{$tables['category']['name']}` WHERE `STATUS` = 2 AND `PARENT_ID` = ".$db->qstr($id)." ORDER BY `TITLE`");
while (!$rs->EOF)
{
$row = $rs->FetchRow();
if ($id == 0 && CATS_PREVIEW > 0)
{
$rs2 = $db->SelectLimit("SELECT * FROM `{$tables['category']['name']}` WHERE `STATUS` = '2' AND `SYMBOLIC` <> 1 AND `PARENT_ID` = ".$db->qstr($row['ID'])." ORDER BY `TITLE` ASC", CATS_PREVIEW);
$row['SUBCATS'] = $rs2->GetRows();
$rs2->Close();
}
if (ENABLE_REWRITE && empty ($row['TITLE_URL']))
{
$row['TITLE_URL'] = preg_replace ('`[^\w_-]`', '_', $row['TITLE']);
$row['TITLE_URL'] = str_replace ('__', '_', $row['TITLE_URL']);
}
if ($row['SYMBOLIC'] == 1)
{
$row['ID'] = $row['SYMBOLIC_ID'];
$tempcat = $db->GetRow("SELECT * FROM `{$tables['category']['name']}` WHERE `ID` = ".$db->qstr($row['SYMBOLIC_ID']));
if (empty ($row['TITLE']))
$row['TITLE'] = $tempcat['TITLE'];
$row['TITLE'] = "@" . $row['TITLE'];
if (ENABLE_REWRITE == 1)
$row['TITLE_URL'] = construct_mod_rewrite_path($row['SYMBOLIC_ID']);
$row['COUNT'] = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `STATUS` = '2' AND `PARENT_ID` = ".$db->qstr($row['SYMBOLIC_ID']));
$row['COUNT'] += $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($row['SYMBOLIC_ID']));
}
else
{
$row['COUNT'] = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `STATUS` = '2' AND `PARENT_ID` = ".$db->qstr($row['ID']));
$row['COUNT'] += $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($row['ID']));
}
$categs[] = $row;
}
$rs->Close();
}
if ($id > 0)
{
$db->Execute("UPDATE `{$tables['category']['name']}` SET `HITS` = `HITS` + 1 WHERE `ID` = ".$db->qstr($id));
}
}
// Paging 4
$tpl->assign('list_total', $count);
// End Paging 4
$tpl->assign('category', $path[count($path) - 1]);
$tpl->assign('path', $path);
$tpl->assign('links', $links);
$tpl->assign('categs', $categs);
//Clean whitespace
$tpl->load_filter('output', 'trimwhitespace');
//Make output
echo $tpl->fetch('main.tpl', $id);
?>
|
|
|
|
09-07-2008, 06:26 AM
|
Re: phplinkdirectory: How to increase number of featured links in main page?
|
Posts: 132
|
Also found nother file init.php
Code:
require_once 'include/version.php';
require_once 'include/config.php';
require_once 'include/tables.php';
require_once 'include/functions.php';
session_start();
define ('DOC_ROOT', substr ($_SERVER["SCRIPT_NAME"], 0, strrpos ($_SERVER["SCRIPT_NAME"], '/')));
if (!defined ('DB_DRIVER'))
{
@ header('Location: '.DOC_ROOT.'/install/index.php');
@ exit;
}
require_once 'libs/intsmarty/intsmarty.class.php';
require_once 'libs/smarty/SmartyValidate.class.php';
require_once 'libs/adodb/adodb.inc.php';
if (get_magic_quotes_gpc())
{
function stripslashes_deep($value)
{
$value = (is_array ($value) ? array_map ('stripslashes_deep', $value) : stripslashes ($value));
return $value;
}
$_REQUEST = array_map ('stripslashes_deep', $_REQUEST);
$_COOKIE = array_map ('stripslashes_deep', $_COOKIE);
}
//Connect to database
$db = ADONewConnection(DB_DRIVER);
if($db->Connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME))
{
$db->SetFetchMode(ADODB_FETCH_ASSOC);
read_config($db);
}
else
define('ERROR', 'ERROR_DB_CONNECT');
if (DEBUG === 1)
set_log('frontend_log.txt');
//Initialize template
$tpl = get_tpl();
$tpl->cache_lifetime = 0;
$tpl->assign('VERSION', CURRENT_VERSION);
require_once 'include/constants.php';
$URLcomponents = @ parse_url ($_SERVER['REQUEST_URI']);
if (is_array ($URLcomponents) && !empty ($URLcomponents))
{
@ parse_str ($URLcomponents['query'], $URLvariables);
}
// LinkStats
require_once 'statistic.php';
//random featured
$random_link = $db->GetAll("SELECT * FROM {$tables['link']['name']} WHERE FEATURED = 1 AND STATUS=2 ORDER BY RAND() LIMIT 3");
$tpl->assign('random_link', $random_link);
?>
Is there anything I can modify here to make more featured links appear in my main page ?
|
|
|
|
09-07-2008, 06:40 AM
|
Re: phplinkdirectory: How to increase number of featured links in main page?
|
Posts: 132
|
Solved! thanks
|
|
|
|
|
« Reply to phplinkdirectory: How to increase number of featured links in main page?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|