Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: easykey on September 11, 2004, 11:31:19 AM

Title: Make a board always sorted by 'subject' as default
Post by: easykey on September 11, 2004, 11:31:19 AM
Is there a way I can sort the topics in one board in alphabetical order of subject?
(ignoring post date)
Is it something I modify in a theme template?

[edit] changed topic title [/edit]
Title: Re: Sort topics by alphabetical order?
Post by: Tom on September 11, 2004, 11:33:05 AM
Just click on "Subject". :)
Title: Re: Sort topics by alphabetical order?
Post by: easykey on September 11, 2004, 02:43:30 PM
Sorry I should have been clearer.

Is there a way I can make one board particulalry open up always sorted by Subject as DEFAULT

(But other boards continue sorting by last post at the top)
Title: Re: Sort topics by alphabetical order?
Post by: [Unknown] on September 11, 2004, 04:21:57 PM
Currently, there is no option for the default sort of boards, but this is something I'd like to add either as a mod or feature.

What you could do is... find in Sources/MessageIndex.php:
// Make sure the starting place makes sense and construct the page index.

Add above it:
if (!isset($_REQUEST['sort']) && $board == BOARD ID HERE!!)
$_REQUEST['sort'] = 'subject';


Where BOARD ID HERE!! is the board, such as 11... (that's this board ;).)

-[Unknown]
Title: Re: Sort topics by alphabetical order?
Post by: Anguz on September 13, 2004, 12:39:36 AM
I'd say this topic is a great candidate for the Tips and Tricks board.
Title: Re: Make a board always sorted by 'subject' as default
Post by: Anguz on October 05, 2004, 11:15:06 PM
http://mods.simplemachines.org/index.php?mod=37 :)
Title: Re: Sort topics by alphabetical order?
Post by: NukeWorker.com on April 17, 2005, 04:32:00 PM
Quote from: [Unknown] on September 11, 2004, 04:21:57 PM
Currently, there is no option for the default sort of boards, but this is something I'd like to add either as a mod or feature.

What you could do is... find in Sources/MessageIndex.php:
// Make sure the starting place makes sense and construct the page index.

Add above it:
if (!isset($_REQUEST['sort']) && $board == BOARD ID HERE!!)
$_REQUEST['sort'] = 'subject';


Where BOARD ID HERE!! is the board, such as 11... (that's this board ;).)

-[Unknown]

This would be a nice addition to SMF 1.1, I've been waiting for this to be an official part of the software for some time now.
Title: Re: Make a board always sorted by 'subject' as default
Post by: [Unknown] on April 17, 2005, 04:33:45 PM
Or you can use the Board Default Sort (http://www.simplemachines.org/community/index.php?topic=17697.0) mod.

-[Unknown]
Title: Re: Make a board always sorted by 'subject' as default
Post by: NukeWorker.com on April 17, 2005, 10:44:05 PM
Does it work in 1.1?  I haven't installed any mods, cause I'm running 1.1 and I don't know what might work, and what might not.
Title: Re: Make a board always sorted by 'subject' as default
Post by: Anguz on April 17, 2005, 11:46:44 PM
Quote from: NukeWorker.com on April 17, 2005, 10:44:05 PM
Does it work in 1.1?

Haven't checked yet, but maybe it does without changes other than the SMF version number.
Title: Re: Make a board always sorted by 'subject' as default
Post by: mank on June 01, 2005, 04:45:53 PM
i couldn't get it to work in beta 2...kept getting a b.sort file error, can't remember what it was exactly but it stopped all forum access :(
Title: Re: Sort topics by alphabetical order?
Post by: onijin on March 18, 2006, 12:31:28 PM
Quote from: [Unknown] on September 11, 2004, 04:21:57 PM
Currently, there is no option for the default sort of boards, but this is something I'd like to add either as a mod or feature.

What you could do is... find in Sources/MessageIndex.php:
// Make sure the starting place makes sense and construct the page index.

Add above it:
if (!isset($_REQUEST['sort']) && $board == BOARD ID HERE!!)
$_REQUEST['sort'] = 'subject';


Where BOARD ID HERE!! is the board, such as 11... (that's this board ;).)

-[Unknown]

Thanks for this.  I had the mod said above on 1.0.6 but I couldn't get it working with 1.1RC2.  This helps.  I'll try it out later.  However, I do have a question:
What if I wanted to do it on multiple boards?  Would I add this:
if (!isset($_REQUEST['sort']) && $board == BOARD ID HERE!!)
$_REQUEST['sort'] = 'subject';

For each board?  Or can I do this:
if (!isset($_REQUEST['sort']) && $board == 4, 5, 8, 11, 14)
$_REQUEST['sort'] = 'subject';

Just once?
Title: Re: Make a board always sorted by 'subject' as default
Post by: onijin on March 21, 2006, 09:53:26 AM
Nevermind.  After hours of searching, I found it.


if (!isset($_REQUEST['sort']) && $board == '17' || $board == '18' || $board == '27' || $board == '29')
$_REQUEST['sort'] = 'subject';
Title: Re: Make a board always sorted by 'subject' as default
Post by: Kindred on March 21, 2006, 09:57:12 AM
use proper coding...


if (!isset($_REQUEST['sort']) && ($board == '17' || $board == '18' || $board == '27' || $board == '29'))
$_REQUEST['sort'] = 'subject';


you should have an additional set of parens around the OR section...
Title: Re: Make a board always sorted by 'subject' as default
Post by: onijin on March 21, 2006, 02:25:07 PM
<-- newb

Elaborate please...

"or"?
Title: Re: Make a board always sorted by 'subject' as default
Post by: jpark on May 22, 2006, 01:46:32 AM
hi, how would I sort by the date of the topic in descending order.  In other words use 'first_post' instead of 'subject' but have the newest topic up at the top?

Also, if I would like this to be the default sort on all of the boards (not just a select few), would I use this code or change the code elsewhere?

Thanks~! :)
Title: Re: Make a board always sorted by 'subject' as default
Post by: onijin on May 22, 2006, 08:51:20 AM
Quote from: jpark on May 22, 2006, 01:46:32 AM
hi, how would I sort by the date of the topic in descending order.  In other words use 'first_post' instead of 'subject' but have the newest topic up at the top?

Isn't this the default, where the newest topics are listed at top?
Title: Re: Make a board always sorted by 'subject' as default
Post by: jpark on May 22, 2006, 11:39:24 AM
i think the default is set to the topic with the newest post up top.. i would like to sort by the original topic date (first post) regardless of the date of the last post.  I hope this is not hijacking.. if there is one simple default sort function addressing anyone's sorting wishes, that would be wonderful!  Thanks~  :)
Title: Re: Make a board always sorted by 'subject' as default
Post by: onijin on May 22, 2006, 12:08:06 PM
Oh~

Sort by Opening Posts... hmm~  I don't know...

Sorry~
Title: Re: Make a board always sorted by 'subject' as default
Post by: jpark on May 22, 2006, 08:08:27 PM
oh.. i think i figured it out (it works at least) but i don't know if the coding is right..
I went to messageindex.php in sources and found:
// They didn't pick one, default to by last post descending.
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
{
$context['sort_by'] = 'last_post';
$_REQUEST['sort'] = 'ID_LAST_MSG';
$ascending = isset($_REQUEST['asc']);
}


and changed it to:
// They didn't pick one, default to by first post descending.
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
{
$context['sort_by'] = 'first_post';
$_REQUEST['sort'] = 'ID_TOPIC';
$ascending = isset($_REQUEST['desc']);
}


can anyone tell me if this is correct?