News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Make a board always sorted by 'subject' as default

Started by easykey, September 11, 2004, 11:31:19 AM

Previous topic - Next topic

easykey

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]

Tom


easykey

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)

[Unknown]

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]

Anguz

I'd say this topic is a great candidate for the Tips and Tricks board.
Cristián Lávaque http://cristianlavaque.com


NukeWorker.com

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.

[Unknown]


NukeWorker.com

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.

Anguz

#9
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.
Cristián Lávaque http://cristianlavaque.com

mank

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 :(

onijin

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?

onijin

Nevermind.  After hours of searching, I found it.


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

Kindred

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...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

onijin


jpark

#15
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~! :)

onijin

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?

jpark

#17
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~  :)

onijin

Oh~

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

Sorry~

jpark

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?

Advertisement: