[REQ] move locked topics to bottom of viewforum?

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
User avatar
thejdm
Registered User
Posts: 438
Joined: Sun Dec 21, 2003 4:18 pm
Location: pennsylvania
Contact:

Re: [REQ] move locked topics to bottom of viewforum?

Post by thejdm »

didnt seem to work.

here is the phpBB2 version, anyone feel like porting to bb3?

Code: Select all

#-----[ OPEN ]------------------------------------------------ 
# 
modcp.php 

# 
#-----[ FIND ]------------------------------------------------ 
# 
ORDER BY t.topic_type DESC

# 
#-----[ IN-LINE FIND ]---------------------------------------- 
# 
t.topic_type DESC

# 
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
# 
, t.topic_status ASC

# 
#-----[ OPEN ]------------------------------------------------ 
# 
search.php 

# 
#-----[ FIND ]------------------------------------------------ 
# 
$sql .= " ORDER BY "; 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

// Start add - Locked at the end MOD
$sql .= ' t.topic_type DESC,t.topic_status ASC, '; 
// End add - Locked at the end MOD

# 
#-----[ OPEN ]------------------------------------------------ 
# 
viewforum.php 

# 
#-----[ FIND ]------------------------------------------------ 
# 
ORDER BY t.topic_type DESC

# 
#-----[ IN-LINE FIND ]---------------------------------------- 
# 
t.topic_type DESC

# 
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
# 
, t.topic_status ASC

# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
www.thejdm.com ...turn it on, y0
User avatar
DeViAnThans3
Registered User
Posts: 877
Joined: Sat Oct 08, 2005 10:39 pm
Location: Belgium

Re: [REQ] move locked topics to bottom of viewforum?

Post by DeViAnThans3 »

Strange, the code I gave you is perfectly working on 2 of my boards, both running version phpBB 3.0.4.
Which MySQL version do you have?
I only provide support via the appropriate topics! Please no PM or mails! :)
My MODs :: [BETA] Facebook Connect
User avatar
thejdm
Registered User
Posts: 438
Joined: Sun Dec 21, 2003 4:18 pm
Location: pennsylvania
Contact:

Re: [REQ] move locked topics to bottom of viewforum?

Post by thejdm »

i re-tried the code and still nothing. all the locked topics just vanish

MySQL version 5.0.51a-community
www.thejdm.com ...turn it on, y0
User avatar
tumba25
Former Team Member
Posts: 4430
Joined: Wed Jun 06, 2007 6:42 am
Location: Kokkola, Finland.
Name: Jari Kanerva
Contact:

Re: [REQ] move locked topics to bottom of viewforum?

Post by tumba25 »

There is two small errors in DeViAnThans3 edits.

Code: Select all

topic_status
in both places should be

Code: Select all

t.topic_status
Need a mod/extension created/installed, other custom-coded solution or a server admin? https://tumba25.net
User avatar
thejdm
Registered User
Posts: 438
Joined: Sun Dec 21, 2003 4:18 pm
Location: pennsylvania
Contact:

Re: [REQ] move locked topics to bottom of viewforum?

Post by thejdm »

i retired with those 2 fixes and it still didn't work. :( ah well. eventually.
www.thejdm.com ...turn it on, y0
mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: [REQ] move locked topics to bottom of viewforum?

Post by mtrs »

thejdm wrote:i retired with those 2 fixes and it still didn't work. :( ah well. eventually.
I tried Johan's code, it works fine for one page forum list, but doesn't send locked topic bottom of last forum llist page.
Also, the code, given later in this topic, to send locked topics down the all list doesn't work.

So, in order to do what thejdm wanted, I improved Johan's code.
But,the way I made it work, needs one more query for the last page of viewforum. Because, I eliminated locked topics until last page sql run, then retrieved locked topic list with another query.
As the code is long, If anyone can make it smaller, it will be better. It works at localhost, but you need to test again.

Open
viewforum.php

Find

Code: Select all

// Grab just the sorted topic ids
$sql = 'SELECT t.topic_id
    FROM ' . TOPICS_TABLE . " t
    WHERE $sql_where
        AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
        $sql_approved
        $sql_limit_time
    ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);

while ($row = $db->sql_fetchrow($result))
{
    $topic_list[] = (int) $row['topic_id'];
}
$db->sql_freeresult($result); 
Replace with

Code: Select all

// Grab just the sorted topic ids

//Begin: Locked topics down in the forum
if ($config['topics_per_page'] > $topics_count)
{    
    $sql = 'SELECT t.topic_id, t.topic_status, t.topic_type
        FROM ' . TOPICS_TABLE . " t
        WHERE $sql_where
            AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
            $sql_approved
            $sql_limit_time
        ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
    $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);

    $closed_topics = array();
    while ($row = $db->sql_fetchrow($result))
    {
       if ($row['topic_status'] == ITEM_LOCKED && $row['topic_type'] == POST_NORMAL)
       {
          $closed_topics[] = (int) $row['topic_id'];
       }
       else
       {
          $topic_list[] = (int) $row['topic_id'];
       }
    }
    $topic_list = array_merge($topic_list, $closed_topics);  
    $db->sql_freeresult($result);

}
else if (floor($start / $config['topics_per_page']) < floor($topics_count / $config['topics_per_page']))
{
    $sql = 'SELECT t.topic_id
        FROM ' . TOPICS_TABLE . " t
        WHERE $sql_where
            AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
            AND (t.topic_status <> (" . ITEM_LOCKED . ") OR t.topic_type = (" . POST_STICKY . "))
            $sql_approved
            $sql_limit_time
        ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
    $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
    while ($row = $db->sql_fetchrow($result))
    {
        $topic_list[] = (int) $row['topic_id'];
    }
}
else
{
    $sql = 'SELECT t.topic_id
        FROM ' . TOPICS_TABLE . " t
        WHERE $sql_where
            AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
            AND (t.topic_status <> (" . ITEM_LOCKED . ") OR t.topic_type = (" . POST_STICKY . "))
            $sql_approved
            $sql_limit_time
        ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
        $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
   
    while ($row = $db->sql_fetchrow($result))
    {
        $topic_list[] = (int) $row['topic_id'];          
    }
    $db->sql_freeresult($result);    
    
    $sql = 'SELECT t.topic_id
    FROM ' . TOPICS_TABLE . " t
    WHERE $sql_where
        AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
        AND (t.topic_status = (" . ITEM_LOCKED . ") AND t.topic_type = (" . POST_NORMAL . "))
        $sql_approved
        $sql_limit_time
    ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
    $result = $db->sql_query_limit($sql, $topics_count, $sql_start);

    $closed_topics = array();
    while ($row = $db->sql_fetchrow($result))
    { 
        $closed_topics[] = (int) $row['topic_id'];
    }
    $db->sql_freeresult($result);

    $topic_list = array_merge($closed_topics, $topic_list);            
}
//End: Locked topics down in the forum 
Edit: Replaced the code, as it was sending locked stickies down the forum too.
Last edited by mtrs on Mon Feb 23, 2009 11:09 am, edited 1 time in total.
I abandoned all of my mods.
User avatar
thejdm
Registered User
Posts: 438
Joined: Sun Dec 21, 2003 4:18 pm
Location: pennsylvania
Contact:

Re: [REQ] move locked topics to bottom of viewforum?

Post by thejdm »

thanks! that worked great!
www.thejdm.com ...turn it on, y0
mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: [REQ] move locked topics to bottom of viewforum?

Post by mtrs »

thejdm wrote:thanks! that worked great!
You need to update that code, because It was also sending locked stickies down, I fixed that and edited my post above. http://www.phpbb.com/community/viewtopi ... 5#p8699435
I abandoned all of my mods.
User avatar
janine
Registered User
Posts: 345
Joined: Sun Mar 24, 2002 6:38 pm
Location: Pa

Re: [REQ] move locked topics to bottom of viewforum?

Post by janine »

Awesome! Thanks for this! :D
User avatar
janine
Registered User
Posts: 345
Joined: Sun Mar 24, 2002 6:38 pm
Location: Pa

Re: [REQ] move locked topics to bottom of viewforum?

Post by janine »

Actually, I had a lot of locked topics and this really screwed up the pagenation :( Bummer Had to take the code out.
User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [REQ] move locked topics to bottom of viewforum?

Post by UseLess »

Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
User avatar
janine
Registered User
Posts: 345
Joined: Sun Mar 24, 2002 6:38 pm
Location: Pa

Re: [REQ] move locked topics to bottom of viewforum?

Post by janine »

This works much better! Thank you so much!! :D
Locked

Return to “[3.0.x] MOD Requests”