Sort topics Alphabetically in a single forum?

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)
Scam Warning
User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by Volksdevil »

Jeroen B wrote:
Brf wrote:
Pietje15 wrote:Then this should work:

Code: Select all

if ($forum_id == 27 || 24 || 29)
{
    $sort_by_text = array('t' => $user->lang['TOPIC_TITLE']);
    $sort_by_sql = array('t' => 't.topic_title');
    $sort_dir = 'a';
} 
The || is the "or" operator :)
That is not how logical operators work. You would use:

Code: Select all

if ($forum_id == 27 || $forum_id == 24 || $forum_id == 29)
You're right! I didn't test it, thanks for this correction.
Hi, I can't get this working for a second forum section. It only works with the first one, the second one just displays by time posted.
I have tried the below.

Code: Select all

if ($forum_id == 16 || $forum_id == 47)
{
    $sort_by_text = array('t' => $user->lang['TOPIC_TITLE']);
    $sort_by_sql = array('t' => 't.topic_title');
    $sort_dir = 'a';
} 
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60

User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by Volksdevil »

I'm trying to get this working gain, but it will only sort the one forum alphabetically. Can anyone help please? :)

This is what I have below:

Code: Select all

if ($forum_id == 16 || $forum_id == 56)
{
    $sort_by_text = array('t' => $user->lang['SUBJECT']);
    $sort_by_sql = array('t' => 't.topic_title');
    $sort_dir = 'a';
}
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60

User avatar
HGN
Former Team Member
Posts: 4706
Joined: Wed Dec 03, 2008 1:53 pm
Location: The Netherlands
Name: Alfred
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by HGN »

You only have one normal topic in forum 56.
Be aware that announcements and sticky topics are treated seperately.

User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by Volksdevil »

I've got it sorted thanks. I just had the forum hidden while testing. I moved the code and it works now for both forums inc 56 which now has a few more topics ;) :)
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60

User avatar
Sylv
Registered User
Posts: 38
Joined: Sun Feb 04, 2007 12:27 am
Location: UK

Re: Sort topics Alphabetically in a single forum?

Post by Sylv »

Jeroen B wrote:If it's only for one single forum, you can try this:

Open: viewforum.php
THis is exactly what I was looking for!!!!!
However,
I don't know if I am missing something, but the only page called viewforum.php I can find is in the language file:
Language ==> en ==> viewforum.php
and in there, I just cannot find what you are showing me to find :|
Jeroen B wrote: Find:

Code: Select all

// Limit topics to certain time frame, obtain correct topic count    
Could you help me please sir?

Here is how my file looks like:
viewforum.php wrote: <?php
/**
*
* viewforum [English]
*
* @package language
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
'ACTIVE_TOPICS' => 'Active topics',
'ANNOUNCEMENTS' => 'Announcements',

'FORUM_PERMISSIONS' => 'Forum permissions',

'ICON_ANNOUNCEMENT' => 'Announcement',
'ICON_STICKY' => 'Sticky',

'LOGIN_NOTIFY_FORUM' => 'You have been notified about this forum, please login to view it.',

'MARK_TOPICS_READ' => 'Mark topics read',

'NEW_POSTS_HOT' => 'New posts [ Popular ]', // Not used anymore
'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', // Not used anymore
'NO_NEW_POSTS_HOT' => 'No new posts [ Popular ]', // Not used anymore
'NO_NEW_POSTS_LOCKED' => 'No new posts [ Locked ]', // Not used anymore
'NO_READ_ACCESS' => 'You do not have the required permissions to read topics within this forum.',
'NO_UNREAD_POSTS_HOT' => 'No unread posts [ Popular ]',
'NO_UNREAD_POSTS_LOCKED' => 'No unread posts [ Locked ]',

'POST_FORUM_LOCKED' => 'Forum is locked',

'TOPICS_MARKED' => 'The topics for this forum have now been marked read.',

'UNREAD_POSTS_HOT' => 'Unread posts [ Popular ]',
'UNREAD_POSTS_LOCKED' => 'Unread posts [ Locked ]',

'VIEW_FORUM' => 'View forum',
'VIEW_FORUM_TOPIC' => '1 topic',
'VIEW_FORUM_TOPICS' => '%d topics',
));

?>
FYI: you won't get a link to my site here, cause I don't want spam.

User avatar
HGN
Former Team Member
Posts: 4706
Joined: Wed Dec 03, 2008 1:53 pm
Location: The Netherlands
Name: Alfred
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by HGN »

Sylv wrote:However,
I don't know if I am missing something, but the only page called viewforum.php I can find is in the language file:
Language ==> en ==> viewforum.php
It is in the root folder.

User avatar
Sylv
Registered User
Posts: 38
Joined: Sun Feb 04, 2007 12:27 am
Location: UK

Re: Sort topics Alphabetically in a single forum?

Post by Sylv »

Alfred:
You the top man!
Thank you so much!
\ :D /
FYI: you won't get a link to my site here, cause I don't want spam.

sal_jim
Registered User
Posts: 9
Joined: Tue Jun 11, 2013 12:13 pm
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by sal_jim »

It is not working on my forum; i have searched alot but could not resolve the issue. need your help please.

I have added the code in the In the file viewforum.php available in the root directory.
Purged the cache; but still topics are not sorted alphabetically in the order from "A" to "Z".
http://projectmanagementforums.com/viewforum.php?f=104

Following is the code i have added:

Code: Select all

    // Permissions check
    if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))
    {
       if ($user->data['user_id'] != ANONYMOUS)
       {
          trigger_error('SORRY_AUTH_READ');
       }

       login_box('', $user->lang['LOGIN_VIEWFORUM']);
    }

    // Sort Glossary Forum
    if ($forum_id == 104)
    {
        $sort_by_text = array('t' => $user->lang['SUBJECT']);
        $sort_by_sql = array('t' => 't.topic_title');
        $sort_dir = 'a';
    }

    // Forum is passworded ... check whether access has been granted to this
    // user this session, if not show login box
    if ($forum_data['forum_password'])
    {
       login_forum_box($forum_data);
    }

User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by Volksdevil »

Do you have the following in your viewforum.php ?

Code: Select all

$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
If so, pop the code below that. That's what worked for me.
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60

sal_jim
Registered User
Posts: 9
Joined: Tue Jun 11, 2013 12:13 pm
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by sal_jim »

Have the code you mentioned in my viewforum.php; change the position of the sorting code but it is still not working. :(
Following is the current full code of my viewforum.php ; wonder what is wrong :?

I have my code working now thanks @Volksdevil "without your help it would not have been possible"

Privteer
Registered User
Posts: 18
Joined: Fri Dec 24, 2010 8:56 pm

Re: Sort topics Alphabetically in a single forum?

Post by Privteer »

Hi all,

I first apologize for my very poor English and I hope I'll find here the solution to my problem.

Earlier in the afternoon, I tried the code modification like you all did in this topic... and it was functioning as expected. Since a few minutes, I used a SEO MOD to configure URLs rewriting... and now, there is no way to make my topics sorting alphabetically...

I have to precise that I used an ID option to skip ID's forum in my new URL's... so I think the problem is coming from here. :oops:

I thought the ID's were keeped "as in" in my Database... but it seems that they also are modified.

My real problem is that I need to rewrite them with no ID's and I really do need also to order my topics in the desired forums.

If you need I can quote in CODE my .htaccess, if it can help ;)

Any idea ?

User avatar
Lumpy Burgertushie
Registered User
Posts: 67741
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Sort topics Alphabetically in a single forum?

Post by Lumpy Burgertushie »

remove whatever changes you made for that SEO stuff. it is of no benefit to you or your members and only causes problems like this to occur.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?

Privteer
Registered User
Posts: 18
Joined: Fri Dec 24, 2010 8:56 pm

Re: Sort topics Alphabetically in a single forum?

Post by Privteer »

hum...
My real problem is that I need to rewrite them with no ID's and I really do need also to order my topics in the desired forums.
the solution you giis the first one coming in a logical simplst solution... that's the reason I precised the quoted sentence ;)

User avatar
martin123456
I've Been Banned!
Posts: 726
Joined: Sat Mar 05, 2011 7:44 pm

Re: Sort topics Alphabetically in a single forum?

Post by martin123456 »

I did it like this
open viewforum.php

find

Code: Select all

$sort_key    = request_var('sk', $default_sort_key);
$sort_dir    = request_var('sd', $default_sort_dir)
replace with

Code: Select all

// $sort_key    = request_var('sk', $default_sort_key);
$sort_key   = ($forum_id == number here) ? request_var('sk', 's') : request_var('sk', $default_sort_key);
// $sort_dir    = request_var('sd', $default_sort_dir);
$sort_dir   = ($forum_id == number here) ? request_var('sd', 'a') : request_var('sd', $default_sort_dir);
To add more forums then you do it like this

Code: Select all

// $sort_key    = request_var('sk', $default_sort_key);
$sort_key   = ($forum_id == number here || $forum_id ==number here) ? request_var('sk', 's') : request_var('sk', $default_sort_key);
// $sort_dir    = request_var('sd', $default_sort_dir);
$sort_dir   = ($forum_id == number here || $forum_id == number here) ? request_var('sd', 'a') : request_var('sd', $default_sort_dir);
Change these parts to your frum id's on both lines number here

Code: Select all

<!-- IF S_CODE_UNTIDY and S_MESS_ON_INDEX Good If_Not_TIDY_Then_SUBMIT -->

Locked

Return to “[3.0.x] MOD Requests”