Changing the order in which posts are listed in a thread

Started by Mike66, June 06, 2021, 07:37:20 AM

Previous topic - Next topic

Mike66

( Split from: https://www.simplemachines.org/community/index.php?topic=456486.0 )

Hi Aleksi

Being able to change the order of a specific topic to display in order of most recent reply after the original post would be a very interesting mod  8)
It would allow us to have a single 'timeline' style topic.

I tried your code in Display.php, I replaced the first bit of code with the second one and changed ('1', '2', '3') to a trial topic of simply ('8975.0'). This didn't work for me and resulted in all topics/replies on the forum not displaying.

But I'm guessing there will be a simple way to achieve this?

Cheers
Mike

Aleksi "Lex" Kilpinen

Quote from: Mike66 on June 06, 2021, 07:37:20 AM
Being able to change the order of a specific topic to display in order of most recent reply after the original post would be a very interesting mod  8)
It would allow us to have a single 'timeline' style topic.
Sorting posts by time actually is the default behaviour of SMF - so most forums shouldn't really need any modifications to achieve that. That is because sorting by ID normally also equals sorting the posts by time.

Quote from: Oldiesmann on October 19, 2011, 11:24:26 AM
SMF does sort the posts based on their ID because in most cases, older posts will have lower IDs. The only way to change this is to physically change the IDs of the posts in the database, or, if you only want them sorted that way for a specific topic or two, change the code that pulls the details to sort them by date for those specific topics.

As to your test, you probably want to try with only the ID, so '8975' instead of '8975.0'.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mike66

Thanks Aleksi

I tried it again (copy attached) without the .0 and got the same result, an error 500 on all topics.
It's not important, just something nice to try and work out  ;)

Forgot to mention I'm running 2.0.18 BTW.

Cheers
Mike

Aleksi "Lex" Kilpinen

Well, I was mainly guessing there - Not my code, and I didn't check it in anyway, plus it was originally posted a decade ago.
A HTTP 500 would indicate a problem with the code of some sorts, your server error log might be able to tell you more.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mike66

No problem, thanks Aleksi, I was just asking as you had put some thought into this question before and have much better php skills than me.

Cheers
Mike

GL700Wing

Quote from: Aleksi "Lex" Kilpinen on June 06, 2021, 08:27:47 AM
Quote from: Mike66 on June 06, 2021, 07:37:20 AM
Being able to change the order of a specific topic to display in order of most recent reply after the original post would be a very interesting mod  8)
It would allow us to have a single 'timeline' style topic.
Sorting posts by time actually is the default behaviour of SMF - so most forums shouldn't really need any modifications to achieve that. That is because sorting by ID normally also equals sorting the posts by time.

Interesting - I recently merged two forums (one was 10 years older than the other) with the assumption that topics listed in 'Last Post' order would be shown in date order as per the date the topic was created but from what I've seen on the screen and in the forum code topics are listed in topic ID order.

I know merging forums is not a common thing to do but because lists of topics that are supposedly sorted by date order are actually sorted by topic ID all the topics that existed on 'Forum A' before the topics from 'Forum B' were imported as part of the merge process are listed after all the topics from 'Forum B' - thankfully most members search for information so I'm probably the only person wh is ware of this ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Aleksi "Lex" Kilpinen

#6
Yeah, merged forums is pretty much the one exception where this really happens - and was also the original reason for this topic to begin with I believe.
I believe the reason for sorting by ID instead of dates is just simplicity and performance.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mike66

Sorry Aleksi - just noticed that the piece of code was suggested by Oldiesmann  :-[

Aleksi "Lex" Kilpinen

No worries, I do think the basic idea in it seems ok - but I'm not at all sure if the code is correct, or if it applies to recent versions still.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mike66

I know the original post was about merging topics, but rather than start a new topic:

Does anybody have any suggestions as to how I could 'show most recent posts at the top' for just one topic, or just one board?

Cheers
Mike

Mike66

Think I have found solution to what I was trying to achieve with the above, I am busy customising the SMF Articles mod.

Had not looked at SMF Articles before, what a great mod !  8)

Cheers
Mike

Steve

DO NOT pm me for support!

Mike66

Almost solved it by customising the SMF Articles mod, but I couldn't quite get the end result that I was looking for.

I'm sure I should be able to come up with a simple CSS snippet that will force an all members default on one single board to most recent reply at the top in the topics in that board ..... I just can't figure it out yet  ;D

Something like: if board ID = (board=2.0) then default reply order = most recent.

It's at times like this that I really wish I was a bit better at coding  :'(

Cheers
Mike

Aleksi "Lex" Kilpinen

No, I don't think that would be doable by CSS, you would also need to reverse page order somehow.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mike66

Quote from: Aleksi "Lex" Kilpinen on June 09, 2021, 07:00:12 AM
No, I don't think that would be doable by CSS, you would also need to reverse page order somehow.

OK, thanks Aleksi, I think I should probably give up on this one.

I thought I might be able to tie it in with "Show most recent posts at the top" in profile look and layout somehow, as this already deals with page order as well.

Cheers
Mike

Advertisement: