Tip for SMF 2.1: Add 'Start Date' to Message Index Sorting

Started by GL700Wing, September 10, 2023, 07:33:54 PM

Previous topic - Next topic

GL700Wing

In response to this request to Order topics by date started for SMF 2.1 from @Steve ...

In ./Sources/MessageIndex.php
Find:
'starter' => 'COALESCE(memf.real_name, mf.poster_name)',Add After:
'date' => 'mf.poster_time',
Find:
'starter' => 'JOIN {db_prefix}messages mf ON (mf.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)',
Add After:
'date' => 'JOIN {db_prefix}messages mf ON (mf.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)',

Find:
$txt['starter'] = $txt['started_by'];Add After:
$txt['date'] = $txt['topic_start_date'];
In ./Themes/default/MessageIndex.template.php
Find:
<div class="info">', $context['topics_headers']['subject'], ' / ', $context['topics_headers']['starter'], '</div>Replace With:
<div class="info">', $context['topics_headers']['subject'], ' / ', $context['topics_headers']['starter'], ' / ', $context['topics_headers']['date'], '</div>
Find:
', $txt['started_by'], ' ', $topic['first_post']['member']['link'], 'Replace With:
', $txt['started_by'], ' ', $topic['first_post']['member']['link'], ' ', $txt['on'], ' ', $topic['first_post']['time'], '
In ./Themes/default/languages/index.english.php
Add to end of file:
$txt['topic_start_date'] = 'Date Started';
You cannot view this attachment.
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

Steve

DO NOT pm me for support!

Steve

DO NOT pm me for support!

GL700Wing

Quote from: Steve on September 17, 2023, 05:06:15 PMAny chance of making this a mod?
Done - 'Topic Start Date on Message Index' mod for SMF 2.0 and 2.1 submitted for approval.
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

Steve

DO NOT pm me for support!

Doug Heffernan

This is a neat tip. Thanks for sharing it and making it into a mod too.

Steve

If I wanted it to not display the time, and still use time as one of it's sorting parameters, would I just remove [time] from Themes/default/MessageIndex.template.php?
DO NOT pm me for support!

GL700Wing

Quote from: Steve on September 18, 2023, 06:10:48 PMIf I wanted it to not display the time, and still use time as one of it's sorting parameters, would I just remove [time] from Themes/default/MessageIndex.template.php?
Yes - you wouldn't make the second code change to ./Themes/default/MessageIndex.template.php

That said, I've had this implemented on my SMF forum for many years - one of which is more than 20 years old - and I find it useful/interesting to know when topics were started ...
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

Steve

Oh! So I wouldn't make the second code change in it's entirety? So the second code change would remain this?

', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
DO NOT pm me for support!

GL700Wing

Quote from: Steve on September 19, 2023, 05:50:18 AMOh! So I wouldn't make the second code change in it's entirety? So the second code change would remain this?

', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
Correct - you wouldn't change that line at all.
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

Steve

DO NOT pm me for support!

GL700Wing

Quote from: Steve on September 19, 2023, 06:06:54 AMThanks GL. Appreciate it.  :) 
You're welcome.

Also, you might be interested in the mod update I just did ...
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

Steve

Quote from: GL700Wing on September 20, 2023, 08:31:48 AMAlso, you might be interested in the mod update I just did ..
I just installed the update and holy crap is that fast!

Awesome work GL!
DO NOT pm me for support!

live627

Quote from: GL700Wing on September 17, 2023, 09:12:32 PM
Quote from: Steve on September 17, 2023, 05:06:15 PMAny chance of making this a mod?
Done - 'Topic Start Date on Message Index' mod for SMF 2.0 and 2.1 submitted for approval.
I''ll be moving this to Now Available then.

Advertisement: