[RC] Today-Yesterday Relative Time

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

[RC] Today-Yesterday Relative Time

Post by ewelin » Fri Jan 19, 2007 9:31 pm

MOD Title: Today-Yesterday Relative Time
MOD Description:This mod will make the Today and Yesterday show up in place of the Date for the corresponding days, along with an option to display the relative time. Also adds the linked title of the last topic replied to in each forum on the index.
MOD Version: 1.1.1a

Welsolutions Topic: Click Here
MOD Download: Download 1.1.1a
MOD Last Update: n/a
Last Stable version: n/a

Demo Board: n/a
Demo Username: n/a
Demo Password: n/a

+ Special thanks to Useless for all of his code tweaks and contributions.
+ based on code from CyberAlien provided at http://www.phpbbstyles.com/viewtopic.php?t=4954#29491

This mod adds a new create_date2 function so that users can easily update it so that the date is displayed with using either today or yesterday instead of the date. Also there is an option to allow relative time which will display how long ago the post was posted. So instead of saying Today at 5:55pm it would say Today, 3hrs, 10mins ago.

On the forum index the Last Post field is updated to display the title of the last topic replied to. The topic title can be set to but cut off after a settable amount of characters and you can also choose your own characters to be displayed at the end of it if you wish. Default is to have it cut down to 18 characters then have "..." added to the end of it.

Check the contrib folder for instructions for making this compatible with Simple Subforums, Subforums Plus and a tweak to allow for there to be a "Day Before Yesterday" as some countries, like Sweden have a word for this. There is also instructions on how to make this mod compatible with UTF-8 coding.

* If you are not using a style sheet or you are just using basic subSilver you will need to add the CSS to 'templates/subSilver/overall_header.tpl' instead of 'templates/subSilver/subSilver.css' as you are not using an external stylesheet. To do this open 'templates/subSilver/overall_header.tpl' and find this code:

Code: Select all

/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */  
@import url("templates/subSilver/formIE.css");  
-->  
</style>
then add the CSS for the mod before it. Also note that some styles sheets will not be named after the template and will have a generic name like style.css. And finally there are a few templates which use a php file for the style sheet and that is usually named style.php.

Code: Select all

##		2007-11-04 - Version 1.1.1a
##			- Added missing Date before Yesterday addon into contrib folder
##			- no other changes from version 1.1.1
##		2007-11-04 - Version 1.1.1
##			- Renamed Today-Yesterday Relative Time MOD
##			- Added changed to admin_users.php - Thanks Ash Hi Fi Zone
##			- Added Subforums Plus, and UTF-8 coding compatibility
##				instructions into the contrib folder.
##			- Updated the Simple Subforums compatibility instructions
##				with a contribution from Lektor
##		2007-01-13 - Version 1.1.0
##			- Added Relative Time option with a setting within 
##				the ACP - Thanks Useless
##			- Added an option to change the character cut off value
##				characters added via the ACP
##			- Updated the code to use the users date format - Thanks 
##				Useless
##			-	Adjusted the language variables so they should be unique.
##			- Reorganized the way the Last Post information is 
##				displayed on the forum index. 
##		2007-01-13 - Version 1.0.2b
##			- Added the Simple Subforums addon. 
##			- Moved the upgrade scripts into the contrib folder. 
##		2005-05-23 - Version 1.0.2a
##			- Added a file for eXtreme Styles 2.2.1 Update Checker. 
##		2005-05-21 - Version 1.0.2
##			- Updated the method of finding the Last Post Topic thus reducing the DB queries 
##		2005-05-08 - Version 1.0.1
##			- Added a linked title of the last topic replied to in each forum.
##			- Added a "by " in front of the posters name.
##		2005-04-27 - Version 1.0.0
##			- Beta 1 is created.... hopefully she works!
Last edited by ewelin on Mon Nov 05, 2007 4:04 pm, edited 3 times in total.

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Post by ewelin » Fri Jan 19, 2007 9:34 pm

For a better history of this mod please read the topic located on phpBBstyles.com

I plan on releasing an update to the simple subforums compatibility shortly. I've also been toying with the idea of adding a DST (Daylight Savings Time) option to the next version. Still haven't decided if that should be a seperate MOD or if it should be included in this so any feedback would be greatly appriciated.

Basically this MOD makes it so you can have today/yesterday displayed with the user selected time format, or you can have today/yesterday displayed with the relative time from when the post was made (ie - 4hrs, 3mins ago) or you can have it setup to display hte users time and date format. Each user can customize the settings as they wish.

User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw » Fri Jan 19, 2007 10:37 pm

Nice! I've made some simmilar: Smart Dates

Instead of adding a second function it adds another (optional) parameter to the existing function. :)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Post by ewelin » Sat Jan 20, 2007 12:18 am

Interesting... a different approach. The main difference being once smart dates is enabled it shows days/time from when the post was made. The relative time part on mine only appears when the post is only 24 hours old. Then it resorts back to the users date format. With mine you've got 2 options, display today-yesterday and display relative time. These settings are board defualt settings as well as user settings. Lets say you've got 3 posts, one made today, one made yesterday and one made on dec 12th. If you can have both enabled then the times like this:

Today, 2hr 3mins ago
Yesterday, 5:35pm
Dec 12, 2007 5:35pm


If you just have today-yesterday enabled they look like this:

Today, 5:35pm
Yesterday, 5:35pm
Dec 12, 2007 5:35pm


If you have just relative time enabled they look like this:

2hr 3mins ago
Jan 18, 2007 5:35pm
Dec 12, 2007 5:35pm


and then of course if you have neither enabled they'd look like this:

Jan 19, 2007 5:35pm
Jan 18, 2007 5:35pm
Dec 12, 2007 5:35pm


The original code from CyberAlien just put in today-yesterday and left room for customization... With the help of Useless, this MOD has taken a face of it's own I think. It combines part of your MOD with the today-yesterday mod and also cleaned up the Last Post section on the forum index to provide more detail. :-D

User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw » Sat Jan 20, 2007 9:18 am

Oh, that's nice! Mine isn't as customizable as that. When are you planning to submit it to the moddb (if at all)?
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Post by ewelin » Sun Jan 21, 2007 1:30 am

Thanks.... it's been quite the work in progess for some time and I'm just glad to finally have the next version out... as for the modDB... I guess we'll see what everyone thinks of it... I know the previous version was extremely popular on phpbbstyles.com and everyone was a fan of it. I'll probably give if a few weeks for ppl to check it out and report back their thoughts. If no changes are needed then i'll probably submit it.

Lektor
Registered User
Posts: 46
Joined: Tue Sep 19, 2006 9:27 pm

Re: [BETA] Today-Yesterday Relative Time

Post by Lektor » Wed Mar 21, 2007 6:30 pm

Pretty nice mod, i like it .. but loocking forward for addon for simple subforums )
Sorry for my English )

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Re: [BETA] Today-Yesterday Relative Time

Post by ewelin » Fri Mar 30, 2007 12:40 am

I'll see if i can update the code for simple subforums.... I do have the code for integrating it with subforums plus which i'm now using on all of my forums. I should have some time in the next week or two to hash out an update.

Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Re: [BETA] Today-Yesterday Relative Time

Post by Hannibal_King » Tue May 15, 2007 4:36 pm

Hello, i am using version 1.0.2a, it is the best version for me and it is also perfect mod :) but i have one tiny request.. this mod is not displaying all characters correctly if the forum coding is on UTF-8 :( can someone help me with this problem? how to fix it please? thanks.

Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Re: [BETA] Today-Yesterday Relative Time

Post by Hannibal_King » Thu May 17, 2007 6:35 am

bump?

Lektor
Registered User
Posts: 46
Joined: Tue Sep 19, 2006 9:27 pm

Re: [BETA] Today-Yesterday Relative Time

Post by Lektor » Thu May 17, 2007 11:01 pm

ewelin wrote: I'll see if i can update the code for simple subforums....
No changes? :) I am looking forward for this addon..
Sorry for my English )

Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Re: [BETA] Today-Yesterday Relative Time

Post by Hannibal_King » Sat May 19, 2007 9:19 pm

hmm, any idea how to do it please? :roll:

linc_06
Registered User
Posts: 3
Joined: Sun Jun 03, 2007 6:40 am

Re: [BETA] Today-Yesterday Relative Time

Post by linc_06 » Wed Jun 06, 2007 5:18 am

hello everyone

Sorry for my mistakes, I am learning english.

I have installed your [BETA] Today-Yesterday Relative Time, its really nice, cool and very useful. Thanks for doing it.

Also, I also have installed MOD [2.0.19] Users viewing forum on Index.

http://www.phpbb.com/community/viewtopi ... 6&t=502832

I have tested it in two forums:

The first have your mod installed. The second doesn't have.

In the first only appears, without number: viewing

In the second appears: (NUMBER) viewing

example: 2 viewing, 8viewing


Could you say what can I do to fix this problem, please?

Thanks a lot for your time and knowledge....

Lektor
Registered User
Posts: 46
Joined: Tue Sep 19, 2006 9:27 pm

Re: [BETA] Today-Yesterday Relative Time

Post by Lektor » Thu Jun 07, 2007 1:32 am

I tired of to wait for the mod for Simple Subforums, so i do it by myself:

Code: Select all

#
# ----- [ OPEN ] ----------
#
viewforum.php
#
# ----- [ FIND ] ----------
#
		$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
			FROM (( " . FORUMS_TABLE . " f
			LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
			LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
			WHERE f.forum_parent = '{$forum_id}'
			ORDER BY f.cat_id, f.forum_order";

#
# ----- [ REPLACE WITH ] ----------
#
      $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_title, t.topic_id  
        FROM ((( " . FORUMS_TABLE . " f  
        LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )  
        LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id )  
        LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )  
        WHERE f.forum_parent = '{$forum_id}'
        ORDER BY f.cat_id, f.forum_order";

#
# ----- [ FIND ] ----------
#
			if ( $subforum_data[$j]['forum_last_post_id'] )
			{
				$last_post_time = create_date($board_config['default_dateformat'], $subforum_data[$j]['post_time'], $board_config['board_timezone']);

				$last_post = $last_post_time . '<br />';

				$last_post .= ( $subforum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($subforum_data[$j]['post_username'] != '' ) ? $subforum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $subforum_data[$j]['user_id']) . '">' . $subforum_data[$j]['username'] . '</a> ';
								
				$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $subforum_data[$j]['forum_last_post_id']) . '#' . $subforum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
}
#
# ----- [ REPLACE WITH ] ----------
#
			if ( $subforum_data[$j]['forum_last_post_id'] )
			{
$last_post_time = create_date2($board_config['default_dateformat'], $subforum_data[$j]['post_time'], $board_config['board_timezone']);

$last_post = '<span class="date-general">' . $last_post_time . '</span>';
$last_post .= $lang['TY-by'] . (( $subforum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($subforum_data[$j]['post_username'] != '' ) ? $subforum_data[$j]['post_username'] . ' ' : $lang['Guest'] ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $subforum_data[$j]['user_id']) . '" style="color:' . $subforum_data[$j]['user_colour'] . '">' . $subforum_data[$j]['username'] . '</a><br>') . $lang['TY-in'];

$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $subforum_data[$j]['forum_last_post_id']) . '#' . $subforum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a> ';

// Trim the topic title to the configured amount from within the ACP
if (strlen($subforum_data[$j]['topic_title']) > $board_config['ty_lastpost_cutoff']) 
{
$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $subforum_data[$j]['topic_id']) . '" title="' . $lang['Go_to_topic'] . $subforum_data[$j]['topic_title'] . '">' . substr($subforum_data[$j]['topic_title'], 0, $board_config['ty_lastpost_cutoff']) . $board_config['ty_lastpost_append'] . '</a>';
} 
else 
{ 
$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $subforum_data[$j]['topic_id']) . '" title="' . $lang['Go_to_topic'] . $subforum_data[$j]['topic_title'] . '">' . $subforum_data[$j]['topic_title'] . '</a>';
}

Thats all..
Sorry for my English )

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Re: [BETA] Today-Yesterday Relative Time

Post by ewelin » Wed Jun 13, 2007 8:29 pm

Hannibal_King wrote:Hello, i am using version 1.0.2a, it is the best version for me and it is also perfect mod :) but i have one tiny request.. this mod is not displaying all characters correctly if the forum coding is on UTF-8 :( can someone help me with this problem? how to fix it please? thanks.
Take a look at this post

Post Reply

Return to “[2.0.x] MODs in Development”