Seite 1 von 1

Kombination "today at" und "last topic"

Verfasst: 14.07.2003 22:04
von eXup
Hi All,

ich habe gesucht und gesucht, aber leider nichts gefunden.

Würde gerne den Mod "Last Topic" zusätzlich zum bereits vorhandenen "Today at" einbauen.
abei lege ich mir momentan die Karten. Hat das schon jemand gemacht und kann mir vielleicht bei
der Änderung im 2. Teil der index.php helfen? - Wäre echt klasse...

Danke schonmal.

Verfasst: 14.07.2003 23:40
von Acid
...hättest mal einen Link zum "Today" Hack?

Verfasst: 15.07.2003 00:13
von eXup
Hmm,

den Link kann ich gerade nicht finden, deshalb hier der Mod den ich meine:

Code: Alles auswählen

################################################################# 
## Mod Title:    Today At/Yesterday At 
## Mod Version:  1.2.1 
## Author:       blulegend 
## Description:  Will show Today At if the post was posted today 
##               Will show Yesterday At if the post was posted yesterday 
## 
##               Modifies in index, viewforum, viewtopic, and search! 
## 
##               Includes code compatible with Daylight Savings Time Mod 
## 
## Installation Level:  Easier than easy! 
## Installation Time:   10-15 Minutes 
## Files To Edit:       6 
## Included Files:      None 
################################################################# 
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites 
################################################################# 
## 
## Author Note: 
## Enjoy! 
## 
################################################################# 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
################################################################# 
# 
#-----[ OPEN ]------------------------------ 
# 

/includes/pageheader.php 

# 
#-----[ FIND around line 70 ]----------------------------------- 
# 

// 
// Parse and show the overall header. 
// 

# 
#-----[ BEFORE, ADD ]----------------------------------- 
# 

// 
// PARSE DATEFORMAT TO GET TIME FORMAT // TODAY AT MOD 
// 
$time_reg = '([gh][[:punct:][:space:]]{1,2}[i][[:punct:][:space:]]{0,2}[a]?[[:punct:][:space:]]{0,2}[S]?)'; 
eregi($time_reg, $board_config['default_dateformat'], $regs); 
$board_config['default_timeformat'] = $regs[1]; 
unset($time_reg); 
unset($regs); 

// 
// GET THE TIME TODAY AND YESTERDAY 
// 
$today_ary = explode('|', create_date('m|d|Y', time(),$board_config['board_timezone'])); 
$board_config['time_today'] = gmmktime(0 - $board_config['board_timezone'] - $board_config['dstime'],0,0,$today_ary[0],$today_ary[1],$today_ary[2]); 
$board_config['time_yesterday'] = $board_config['time_today'] - 86400; 
unset($today_ary); 

# 
#-----[ OPEN ]------------------------------ 
# 

/index.php 

# 
#-----[ FIND around line 380 ]----------------------------------- 
# 

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

# 
#-----[ REPLACE WITH ]----------------------------------- 
# 

                        // OLD 
                        // $last_post = $last_post_time . '<br />'; 
                        // 
                        // TODAY AT MOD 
                        // 
                        if ( $board_config['time_today'] < $forum_data[$j]['post_time']) 
                        { 
                           $last_post = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />'; 
                        } 
                        else if ( $board_config['time_yesterday'] < $forum_data[$j]['post_time']) 
                        { 
                           $last_post = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />'; 
                        } 
                        else 
                        { 
                           $last_post = $last_post_time . '<br />'; 
                        } 
                        // END MOD 

# 
#-----[ OPEN ]------------------------------ 
# 

/search.php 

# 
#-----[ FIND around line 745 ]----------------------------------- 
# 

         $post_date = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); 

# 
#-----[ AFTER, ADD ]----------------------------------- 
# 

         // 
         // TODAY AT MOD 
         // 
         if ( $board_config['time_today'] < $searchset[$i]['post_time']) 
         { 
            $post_date = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone'])); 
         } 
         else if ( $board_config['time_yesterday'] < $searchset[$i]['post_time']) 
         { 
            $post_date = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone'])); 
         } 
         // END MOD 

# 
#-----[ FIND around line 1120 ]----------------------------------- 
# 

            $last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); 

# 
#-----[ AFTER, ADD ]----------------------------------- 
# 

            // 
            // TODAY AT MOD 
            // 
            if ( $board_config['time_today'] < $searchset[$i]['post_time']) 
            { 
               $last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone'])); 
            } 
            else if ( $board_config['time_yesterday'] < $searchset[$i]['post_time']) 
            { 
               $last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone'])); 
            } 
            // END MOD 

# 
#-----[ OPEN ]------------------------------ 
# 

/viewforum.php 

# 
#-----[ FIND around line 630 ]----------------------------------- 
# 

      $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']); 

# 
#-----[ AFTER, ADD ]----------------------------------- 
# 

      // 
      // TODAY AT MOD 
      // 
      if ( $board_config['time_today'] < $topic_rowset[$i]['post_time']) 
      { 
         $last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone'])); 
      } 
      else if ( $board_config['time_yesterday'] < $topic_rowset[$i]['post_time']) 
      { 
         $last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone'])); 
      } 
      // END MOD 

# 
#-----[ OPEN ]------------------------------ 
# 

/viewtopic.php 

# 
#-----[ FIND around line 806 ]----------------------------------- 
# 

   $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']); 

# 
#-----[ AFTER, ADD ]----------------------------------- 
# 

   // 
   // TODAY AT MOD 
   // 
   if ( $board_config['time_today'] < $postrow[$i]['post_time']) 
   { 
      $post_date = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $postrow[$i]['post_time'], $board_config['board_timezone'])); 
   } 
   else if ( $board_config['time_yesterday'] < $postrow[$i]['post_time']) 
   { 
      $post_date = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $postrow[$i]['post_time'], $board_config['board_timezone'])); 
   } 
   // END MOD 

# 
#-----[ OPEN ]------------------------------ 
# 

/language/lang_xxx/lang_main.php 

# 
#-----[ FIND at end of file ]----------------------------------- 
# 

// 
// That's all Folks! 
// ------------------------------------------------- 

# 
#-----[ BEFORE, ADD ]----------------------------------- 
# 

// TODAY AT MOD 
$lang['Today_at'] = "Today at %s"; // %s is the time 
$lang['Yesterday_at'] = "Yesterday at %s"; // %s is the time 
// 

# 
#-----[ SAVE/CLOSE ALL FILES ]----------------------------------- 
# EoM

Den habe ich eingebaut, und habe jetzt das Problem, dass die index.php dadurch ja schon verändert wurde.
Dort wo der "last topic" diese Veränderung erfordert

Code: Alles auswählen

#
#-----[ ACTION Find ]-----------------------------------------
#
	if ( $forum_data[$j]['forum_last_post_id'] )
	{
	...
	}


#
#-----[ ACTION Replace With ]---------------------------------
#
	if ( $forum_data[$j]['forum_last_post_id'] )
	{
		$topic_title = $forum_data[$j]['topic_title'];
		$topic_title2 = $forum_data[$j]['topic_title'];
		
		//
		// Censor topic title
		//
		if ( count($orig_word) )
		{
			$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
			$topic_title2 = preg_replace($orig_word, $replacement_word, $topic_title2);
		}
										
		if (strlen($topic_title)>27) {
			$topic_title = substr($topic_title,0,24) . '...';
		}

		$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
		$last_post = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '" title="' . $topic_title2 . '">' . $topic_title . '</a><br>';
		$last_post .= $last_post_time . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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><br>' . $lang['by'] . '&nbsp;';
		$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
	}

stehe ich auf dem Schlauch.

Meine index.php sieht in dem Bereich so aus:

Code: Alles auswählen

if ( $forum_data[$j]['forum_last_post_id'] )
							{
								$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);

								// OLD 
                        // $last_post = $last_post_time . '<br />'; 
                        // 
                        // TODAY AT MOD 
                        // 
                        if ( $board_config['time_today'] < $forum_data[$j]['post_time']) 
                        { 
                           $last_post = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />'; 
                        } 
                        else if ( $board_config['time_yesterday'] < $forum_data[$j]['post_time']) 
                        { 
                           $last_post = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />'; 
                        } 
                        else 
                        { 
                           $last_post = $last_post_time . '<br />'; 
                        } 
                        // END MOD

								$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
								
								$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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>';
							}
							else
							{
								$last_post = $lang['No_Posts'];
							}

							if ( count($forum_moderators[$forum_id]) > 0 )
							{
								$l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
								$moderator_list = implode(', ', $forum_moderators[$forum_id]);
							}
							else
							{
								$l_moderators = '&nbsp;';
								$moderator_list = '&nbsp;';
							}

							$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
							$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

(Sorry für die langen Codes)

Verfasst: 15.07.2003 01:07
von Henne
Versuch mal das (keine Garantie, da von mir kopiert und ich nicht weiß, ob es Versionskonflikte mit deiner Version gibt):

Code: Alles auswählen

if ( $forum_data[$j]['forum_last_post_id'] ) 
   { 
      $topic_title = $forum_data[$j]['topic_title']; 
      $topic_title2 = $forum_data[$j]['topic_title']; 
       
      // 
      // Censor topic title 
      // 
      if ( count($orig_word) ) 
      { 
         $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); 
         $topic_title2 = preg_replace($orig_word, $replacement_word, $topic_title2); 
      } 
                               
      if (strlen($topic_title)>27) { 
         $topic_title = substr($topic_title,0,24) . '...'; 
      } 

      $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']); 
      $last_post = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '" title="' . $topic_title2 . '">' . $topic_title . '</a><br>'; 
      // $last_post .= $last_post_time . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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><br>' . $lang['by'] . '&nbsp;'; 
      //$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> '; 
   
   
	// TODAY AT MOD
	//
	if ( $board_config['time_today'] < $forum_data[$j]['post_time'])
	{
		$last_post .= sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']) . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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><br>' . $lang['by'] . '&nbsp;');
	}
		else if ( $board_config['time_yesterday'] < $forum_data[$j]['post_time'])
		{
			$last_post .= sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']) . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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><br>' . $lang['by'] . '&nbsp;');
		}
			else
		{
			$last_post .= $last_post_time . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_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><br>' . $lang['by'] . '&nbsp;';
		}
	
	$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
   } 

Verfasst: 15.07.2003 08:20
von eXup
Hi Henne23,

vielen Dank für den Code.

Funktioniert 1A!

Verfasst: 15.07.2003 14:34
von Angela Goldig
danke. ich hatte das gleiche problem :)

Verfasst: 17.08.2003 18:08
von mikey
ich auch. danke dafür.