PHPLinkDirectory help needed

Discussion in 'Directories' started by super, Mar 24, 2007.

  1. #1
    I use free version of that v 2.1
    And my question- do you know how can I make new submitted links appear on top of the category?, now they goes to bottom. New must be on top, whats the purpose of directory if new additions goes to the bottom and same old ones stays on top forever.
    I asked that in their support forum, but nobody was able to help, they showed me few codes but they did not work...

    Anybody had same trouble ( I mean nobody wants old links on top all the time, so i guess many had this problem) and how did you resolve that?
     
    super, Mar 24, 2007 IP
  2. Antonio

    Antonio Well-Known Member

    Messages:
    1,504
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    155
    #2
    I think you need a custom mods, phpld doesn't offer this feature.

    Maybe you can ask Anon for help :)
     
    Antonio, Mar 24, 2007 IP
  3. an0n

    an0n Prominent Member

    Messages:
    5,688
    Likes Received:
    915
    Best Answers:
    0
    Trophy Points:
    360
    #3
    sort by DATE_ADDED.

    modify your index.php

    $links = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `STATUS` = '2' AND `CATEGORY_ID` = ".$db->qstr($id)." {$feat_where} {$expire_where} ORDER BY DATE_ADDED, `{$sort_cols[$sort]}` {$sort_ord[$sort]} {$limit}");

    that shoudl take care of it for the regular links.
    I really don't bother with 2.1 stuff.
     
    an0n, Mar 24, 2007 IP
  4. dargre

    dargre Peon

    Messages:
    1,007
    Likes Received:
    161
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ......
    OK, post edited, as AnOn already answered.
     
    dargre, Mar 24, 2007 IP
    super likes this.
  5. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #5
    But it did not change anything for me :( :( New links still go to the bottom... Looks like x-files for me- works for everybody except me..

    Ps- here is my code, did i do something wrong? I made it bold- the part an0n posted.. Also i even added "Date_added" in few other spots in this same index file after this did not fork... :(



    require_once 'init.php';

    define('DIR_LPP', 20);
    $sort_cols = array ('D' => _L('Date Added'), 'P' => 'PAGERANK', 'H' => 'HITS', 'A' => 'TITLE');
    $sort_ord = array ('D' => 'DESC' , '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 `DATE_ADDED` 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 `DATE_ADDED` 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 DATE_ADDED, {$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 `DATE_ADDED` 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 DATE_ADDED,`{$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);
    ?>
     
    super, Mar 24, 2007 IP
  6. an0n

    an0n Prominent Member

    Messages:
    5,688
    Likes Received:
    915
    Best Answers:
    0
    Trophy Points:
    360
    #6
    Take this to the phpLD forums.

    When you start posting entire tpl files, that's where it needs to be.
     
    an0n, Mar 24, 2007 IP
  7. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #7
    I posted there, i see even you replied there, but nobody was able to help...
     
    super, Mar 24, 2007 IP
  8. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #8
    Thanks mate, your help was appreciated a lot, since i had this problem for weeks and nobody could help me before
     
    super, Mar 24, 2007 IP