Topic Start Date on Message Index

Started by GL700Wing, September 19, 2023, 03:26:09 PM

Previous topic - Next topic

GL700Wing

Link to the mod

Topic Start Date on Message Index - v1.3

By default the date/time a topic was started is not shown on the Message Index so it is not possible to sort topics by their start date/time.

This modification displays the date/time a topic was started beside the name of the member who started the topic and also adds the option to sort topics by their start date/time.


Release History:
1.0 - 18-Sep-23
o Initial Release

1.1 - 20-Sep-23
o Added mod setting to configure custom date/time format for topic start date on Message Index (includes option to hide topic start date on Message Index).
o Reduced core file edits by using hooks where possible.

1.2 - 14-Nov-23
o Added option to hide the time when the 'Shorthand Date Display' option is enabled (ie, when 'Today' and/or 'Yesterday' are shown).
o As per Steve's request added option to hide start date/time unless sorting topics by date/time.
o Added support for an alternate text string to use instead of $txt['date']
   (Note: Alternate text string name is $txt['tsdomi_date'] and it's in the Modifications language file).
o SMF 2.0: Fixed bug reported by FragaCampos that occurred when sorting by date and changing pages in boards with multiple topic pages.

1.3 - 15-Nov-23
o Fixed bug reported by Steve that occurred when the 'Hide start date/time unless sorting topics by date/time.'  option is enabled, a board was viewed for the first time and the first sort done was by topic start date.





License
Copyright 2023 Kathy Leslie

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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

GL700Wing

Version 1.1 - 20-Sep-23
o Added mod setting to configure custom date/time format for topic start date on Message Index (includes option to hide topic start date on Message Index).
o Reduced core file edits by using hooks where possible.


There is now a mod setting to enable the date/time format for the topic start date on the Message Index to be different to the user or system specified date/time format.

In addition, if a value of 'None' is entered for the mod setting the topic start date will not be shown on the Message Index but users will still be able to sort topics in ascending/descending start date order.
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:30:14 AMThere is now a mod setting
Where is this setting and shouldn't the installation page automatically redirect to where the setting is?

Edit: I found the setting, just missed it somehow the first time but my second question still stands.
DO NOT pm me for support!

GL700Wing

#3
Quote from: Steve on September 20, 2023, 08:53:30 AM
Quote from: GL700Wing on September 20, 2023, 08:30:14 AMThere is now a mod setting
Where is this setting and shouldn't the installation page automatically redirect to where the setting is?

Edit: I found the setting, just missed it somehow the first time but my second question still stands.
Good call - I'll update the package installer to redirect to the mod setting.


Edit: Done!
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

Thanks GL!

Rhetorical question, do you ever sleep?  :laugh:
DO NOT pm me for support!

GL700Wing

Quote from: Steve on September 21, 2023, 06:17:43 AMThanks GL!

Rhetorical question, do you ever sleep?  :laugh:
Yeah - but because the timezone I live in is 14 hours different to the timezone you live in I'm probably asleep during the middle of your day ... ;)
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

FragaCampos

I want to thank you for this, @GL700Wing. After years (!!!) missing this great and useful feature, my forum members are happy.  :)
It's working without errors in a heavy modded forum.


A small contribution:
<file name="$languagedir/Modifications.portuguese_pt-utf8.php" error="skip">
    <operation> <!-- End of File -->
        <search position="end" />
        <add><![CDATA[
// Topic Start Date on Message Index mod
$txt['topic_start_date_mod'] = '<dt><b>Data de Início de Tópico no Índice de Mensagens</b></dt>';
$txt['topic_start_date_time_format'] = 'Formato da data/hora de início para tópicos no Índice de Mensagens';
$txt['topic_start_date_time_format_info'] = 'Introduza o formato de data/hora, a palavra <b>\'None\'</b> para esconder a data/hora de início do tópico, ou deixe em branco para usar o formato de data/hora especificado pelo sistema/utilizador.';
]]></add>
    </operation>
</file>

Requests:
- Would it be possible to add a new string in order to change the "Date" word, on the top of the board index?
- As it is now, when a topic was created yesterday, the mod shows the time after the word "yesterday" in english format. Would be possible to change the format or remove the hour entirely?


Regards.

FragaCampos

I found a bug.
Don't know if it's exclusive to my forum, but when I change from page 1 (where everything is ok) to page 2 (or any other) I get an error message.

Steve

Just an FYI, it works perfectly on mine.
DO NOT pm me for support!

GL700Wing

#9
Quote from: FragaCampos on October 25, 2023, 07:20:56 PMI want to thank you for this, @GL700Wing. After years (!!!) missing this great and useful feature, my forum members are happy.  :)
It's working without errors in a heavy modded forum.
@FragaCampos - You're welcome!

QuoteA small contribution:
<file name="$languagedir/Modifications.portuguese_pt-utf8.php" error="skip">
    <operation> <!-- End of File -->
        <search position="end" />
        <add><![CDATA[
// Topic Start Date on Message Index mod
$txt['topic_start_date_mod'] = '<dt><b>Data de Início de Tópico no Índice de Mensagens</b></dt>';
$txt['topic_start_date_time_format'] = 'Formato da data/hora de início para tópicos no Índice de Mensagens';
$txt['topic_start_date_time_format_info'] = 'Introduza o formato de data/hora, a palavra <b>\'None\'</b> para esconder a data/hora de início do tópico, ou deixe em branco para usar o formato de data/hora especificado pelo sistema/utilizador.';
]]></add>
    </operation>
</file>
Are you also able to provide me with the non-UTF8 language 'portuguese_pt' strings?

Quote- Would it be possible to add a new string in order to change the "Date" word, on the top of the board index?
Hmm - I can but I'll make this an optional string (ie, it can just be added to your language files) so that I don't have to update language files for those who are happy to use the default word.

I've decided that the new string will be called 'tsdomi_date' so if you let me know what text you want displayed I'll update the next version of the mod to include it for you.

Quote- As it is now, when a topic was created yesterday, the mod shows the time after the word "yesterday" in english format.
The mod uses the system default language strings so the word 'yesterday' (and 'today') should be displayed in your local language - is this not happening?

QuoteWould be possible to change the format ...
The mod provides you with the option to specify the start date/time format for topics on Message Index - have you tried changing the format via this option/setting?

Quote... or remove the hour entirely?
Sure - I can update the mod to remove the time when either 'today' or 'yesterday' are shown.

For this I need the following mod setting language string translated:
$txt['topic_start_date_time_shorthand'] = 'Remove timestamp for ' . strtok($txt['today'], " ") . ' and/or ' . strtok($txt['yesterday'], " ") . ' if <i>\'Enable shorthand date display\'</i> setting is <b>not</b> disabled.';
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

GL700Wing

Quote from: FragaCampos on October 26, 2023, 12:56:04 PMI found a bug.
Don't know if it's exclusive to my forum, but when I change from page 1 (where everything is ok) to page 2 (or any other) I get an error message.
I can't reproduce this error ...
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

Keep in mind @GL700Wing that @FragaCampos's forum is heavily modded. Possibly a conflict with one of his mods (standard/custom). As I said above, I have quite a few mods on my forum and I don't have that problem.
DO NOT pm me for support!

FragaCampos

Quote from: GL700Wing on October 30, 2023, 06:08:19 AMAre you also able to provide me with the non-UTF8 language 'portuguese_pt' strings?

Sure, here it goes:

<file name="$languagedir/Modifications.portuguese_pt-utf8.php" error="skip">
    <operation> <!-- End of File -->
        <search position="end" />
        <add><![CDATA[
// Topic Start Date on Message Index mod
$txt['topic_start_date_mod'] = '<dt><b>Data de In&iacute;cio de T&oacute;pico no &Iacute;ndice de Mensagens</b></dt>';
$txt['topic_start_date_time_format'] = 'Formato da data/hora de in&iacute;cio para t&oacutepicos no &Iacute;ndice de Mensagens';
$txt['topic_start_date_time_format_info'] = 'Introduza o formato de data/hora, a palavra <b>\'None\'</b> para esconder a data/hora de in&iacutecio do t&oacutepico, ou deixe em branco para usar o formato de data/hora especificado pelo sistema/utilizador.';
]]></add>
    </operation>
</file>




Quote from: GL700Wing on October 30, 2023, 06:08:19 AMHmm - I can but I'll make this an optional string (ie, it can just be added to your language files) so that I don't have to update language files for those who are happy to use the default word.

I've decided that the new string will be called 'tsdomi_date' so if you let me know what text you want displayed I'll update the next version of the mod to include it for you.

Great! Here's the text to be displayed "Data de criação"


Quote from: GL700Wing on October 30, 2023, 06:08:19 AMThe mod uses the system default language strings so the word 'yesterday' (and 'today') should be displayed in your local language - is this not happening?

Sorry, I must have made some mistake. It does use the system default language. All is good here.



Quote from: GL700Wing on October 30, 2023, 06:08:19 AMSure - I can update the mod to remove the time when either 'today' or 'yesterday' are shown.

Great.  8)
Here's the requested string translated.

$txt['topic_start_date_time_shorthand'] = 'Remover hora para ' . strtok($txt['today'], " ") . ' e/ou ' . strtok($txt['yesterday'], " ") . ' se a definição <i>\'Ativar versão curta da data\'</i> <b>não</b> estiver desativada.';



Quote from: GL700Wing on October 30, 2023, 06:42:13 AMI can't reproduce this error ...

Here's a short video to illustrate what happens. Maybe it helps.
https://mega.nz/file/bh8ABJZB#3Wpgmgdxf3Zwia4FXoooIIcv1QpttkL25mQvcjIt5Tk
If you think it's useful, I can share my MessageIndex.php file.

GL700Wing

Thanks for the language strings.

QuoteIf you think it's useful, I can share my MessageIndex.php file.
The video shows what is happening but not why - if you can share your MessageIndex.php file I will try and work out why this is happening.
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

FragaCampos

Of course. Here it is attached.


Thank you once more.

GL700Wing

Quote from: FragaCampos on October 30, 2023, 10:18:36 PMOf course. Here it is attached.
OK - from what I can see the two edits that should have been applied to MessageIndex.php when the mod was installed are missing - did you add this feature to your forum using the Tip/Trick or by using the mod installer?

I have confirmed that the mod installer should have been able to make the required changes to your MessageIndex.php file without any issues (ie, the changes made by the mod installer would not have conflicted with other mods that are already installed and/or custom code changes that have been made).

Attached is a copy of what your MessageIndex.php file should have looked like when it was updated using either the Tip/Trick information or the mod installer (Line 88 has been updated and Line 293 has been inserted).

QuoteThank you once more.
You're welcome.
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

FragaCampos

I'm sorry, I sent you the file after uninstalling the mod, but I can confirm that all edits were made via installation in the SMF admin panel without errors.
I've tried the file you edited, which is equal to the file with the mod installed, and the error persists...  :P

GL700Wing

Quote from: FragaCampos on October 31, 2023, 08:58:52 AMI'm sorry, I sent you the file after uninstalling the mod, but I can confirm that all edits were made via installation in the SMF admin panel without errors.
I've tried the file you edited, which is equal to the file with the mod installed, and the error persists...  :P
OK - looks like there is a conflict with the version of the Topic Rating Bar mod you have installed. 

Happy to try and get this mod to work with the version of the Topic Rating Bar mod you have installed but to do so I will need a copy of the Topic Rating Bar mod package file from your forum (the only SMF 2.0 version I can find is 'hooks only' and does not modify MessageIndex.php).
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

FragaCampos

I don't know if I can share a customized mod here, so, if you don't mind, I can send it to you via PM.

GL700Wing

Quote from: FragaCampos on November 01, 2023, 04:35:37 PMI don't know if I can share a customized mod here, so, if you don't mind, I can send it to you via PM.
AFAIK you can't attach files to PMs and I believe that in a situation like this it wouldn't be a problem if you attach it to a message and then delete it as soon as I've downloaded it.
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

@GL700Wing should be able to edit your post after she's downloaded the attachment and remove it. Any staff member can do it.
DO NOT pm me for support!

Steve

Hey @GL700Wing - would it be relatively easy to not have the date/time show unless the topics are sorted by date?

Just curious.
DO NOT pm me for support!

GL700Wing

Quote from: Steve on November 10, 2023, 06:53:54 PMHey @GL700Wing - would it be relatively easy to not have the date/time show unless the topics are sorted by date?

Just curious.
Hey @Steve - Yep!  New version on the way with option to hide start date/time unless sorting topics by start date ...
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

Version 1.2 - 14-Nov-23
o Added option to hide the time when the 'Shorthand Date Display' option is enabled (ie, when 'Today' and/or 'Yesterday' are shown).
o As per Steve's request added option to hide start date/time unless sorting topics by date/time.
o Added support for an alternate text string to use instead of $txt['date']
   (Note: Alternate text string name is $txt['tsdomi_date'] and it's in the Modifications language file).
o SMF 2.0: Fixed bug reported by FragaCampos that occurred when sorting by date and changing pages in boards with multiple topic pages.


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

@GL700Wing - I spoke too soon. Each time I access a board and each time I sort by date I get errors:

Type of error
Undefined_vars
Error message
2: Undefined array key "sort"
File
/home/steve/public_html/forums/Themes/GreyedOut/MessageIndex.template.php
Line
245

Backtrace:

#0: smf_error_handler()
Called from /home/steve/public_html/forums/Themes/GreyedOut/MessageIndex.template.php on line 245
#1: template_main()
Called from /home/steve/public_html/forums/Sources/Load.php on line 2783
#2: loadSubTemplate()
Called from /home/steve/public_html/forums/Sources/Subs.php on line 4186
#3: obExit()
Called from /home/steve/public_html/forums/index.php on line 187

Same errors if I'm on Curve 2.

The error does not occur if I uncheck the 'Hide start date/time unless sorting topics by date/time.' box.
DO NOT pm me for support!

GL700Wing

Version 1.3 - 15-Nov-23
o Fixed bug reported by Steve that occurred when the 'Hide start date/time unless sorting topics by date/time.'  option is enabled, a board was viewed for the first time and the first sort done was by topic start date.
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

Thanks GL. Works a treat now.
DO NOT pm me for support!

FragaCampos

Thanks a million, GL700Wing!
With these bug fixes, it's working flawlessly.  8)

Steve

Just curious @GL700Wing, why only the message index?

Can't it be the sort order for all pages in the index so that I don't have to resort each time I go to a topic and/or change pages in that topic when I'm reading it?

This is more of a wish on my wish list than a request. So, don't go trying to redo the mod.  :)
DO NOT pm me for support!

GL700Wing

#31
Quote from: Steve on May 06, 2024, 12:18:25 PMJust curious @GL700Wing, why only the message index?

Can't it be the sort order for all pages in the index so that I don't have to resort each time I go to a topic and/or change pages in that topic when I'm reading it?

This is more of a wish on my wish list than a request. So, don't go trying to redo the mod.  :)
Sorry but I don't understand your question - if you want to always display the most recent messages at the top when a topic is displayed you can enable the Show most recent posts at the top. via the Look and Layout menu in your profile.
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

Arantor

I think what he's getting at is that the sort is done - but when he goes into a topic and back to the message index, it's no longer sorted that way?

(To be fair, none of the sorting options persist in this way. Start date isn't unique in that respect.)
Holder of controversial views, all of which my own.

Steve

What about if I'm looking at a multi-page topic, and I go to a different page in that same topic, I have to sort by Date again? For example, if I'm looking at page 2 of the topic and click page 5, why do I have to resort again?

Again, this is just a wishlist item. Not something you should spend any of your vacation time on.  ;D
DO NOT pm me for support!

Arantor

Because it's for the list of topics, not the contents of a topic?

Not sure what pages of a topic have to do with it, tbh?
Holder of controversial views, all of which my own.

GL700Wing

Quote from: Steve on May 08, 2024, 08:08:06 AMWhat about if I'm looking at a multi-page topic, and I go to a different page in that same topic, I have to sort by Date again? For example, if I'm looking at page 2 of the topic and click page 5, why do I have to resort again?

Again, this is just a wishlist item.
Hmm - will see what I can do later this year ...

QuoteNot something you should spend any of your vacation time on.  ;D
Zero chance of that happening!!  :P
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: Arantor on May 08, 2024, 12:48:23 PMBecause it's for the list of topics, not the contents of a topic?
Well duh on my apparently non-functioning brain! Thanks @Arantor;D

Quote from: GL700Wing on May 08, 2024, 05:24:35 PMZero chance of that happening!!
Lol! The way it should be!  :laugh:
DO NOT pm me for support!

Cal O'Shaw

I am on 2.1.4, had installed v1.1.1 and was fine.

Installed 1.1.3 and I now had the start date TWICE.

Deleted 1.1.3 and I had NO POSTS on any board.

Reinstalled 1.1.3 and I now have THREE start dates.

It appears the start date code gets appended each time, rather than seeing it's already present.

What file do I need to edit in order to remove the extra ' on ' start times?

Kindred

Yes, if you install multiple copies of a mod,it will often install multiples code lines.

You need to MANUALLY go through the install instructions and remove the duplicated lines
Сл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."

Cal O'Shaw

Just did that.  Finally figured out where they were located.  cpanel search feature is horrible, but that's beside the point.

Thank you for clarifying for me. 

Advertisement: