Similar topics - My changes

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Benutzeravatar
Poruchik
Mitglied
Beiträge: 12
Registriert: 16.01.2006 21:21
Kontaktdaten:

Similar topics - My changes

Beitrag von Poruchik »

Excuse me please for bad English.
Additional SQL (5-6) turn out too many at viewing a topic.
There are still defects of it a mod.
Instead of the author of a topic the name of the participant which has made last message in a topic is deduced.
Topics which are in the closed forums are displayed.
I offer the changes.

Code: Alles auswählen

# 
#-----[ OPEN ]------------------------------------------ 
# 
viewtopic.php 

# 
#-----[ FIND ]------------------------------------------ 
# 
$sql = "SELECT topic_id
FROM ". TOPICS_TABLE ."
WHERE topic_id != $topic_id
AND MATCH (topic_title) AGAINST ('". addslashes($topic_title) ."')
ORDER BY topic_time DESC LIMIT 0,5";

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
$forums_auth_sql = '';

// If necessary delete the / * to uncomment the block.
/*
// Get forum auth information to insure privacy of hidden topics
//
$forums_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
foreach($forums_auth as $k=>$v)
{
	if( $v['auth_view'] && $v['auth_read'] )
	{
		$forums_auth_sql .= (( $forums_auth_sql == '' ) ? '': ', ') . $k;
	}
}
if ($forums_auth_sql != '')	
{
	$forums_auth_sql = ' AND t.forum_id IN (' . $forums_auth_sql . ') ';
}
// Delete the following line, to uncomment this block
*/

$sql = "SELECT t.*, u.user_id, u.username, f.forum_id, f.forum_name, p.post_time, p.post_username
			FROM ". TOPICS_TABLE ." t, ". USERS_TABLE ." u, ". FORUMS_TABLE ." f, ". POSTS_TABLE ." p
			WHERE t.topic_id <> $topic_id $forums_auth_sql
			AND MATCH (t.topic_title) AGAINST ('" . addslashes($topic_title) . "')
			AND f.forum_id = t.forum_id
			AND p.post_id = t.topic_last_post_id
			AND t.topic_poster = u.user_id
			GROUP BY t.topic_id
			ORDER BY t.topic_last_post_id DESC LIMIT 0,5";

# 
#-----[ FIND ]------------------------------------------ 
# 
$topics = array();
while ( $row = $db->sql_fetchrow($result) )
{
  $topics[] = $row;
}
  $count_similar = count($topics);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
$similar_topics = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$count_similar = count($similar_topics);

# 
#-----[ FIND ]------------------------------------------ 
# 
for($i = 0; $i < $count_similar; $i++)
{
  $sql = "SELECT t.topic_type, t.topic_status, t.topic_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_last_post_id, u.user_id, u.username, f.forum_id, f.forum_name, p.post_time, p.post_username
  FROM ". TOPICS_TABLE ." t, ". USERS_TABLE ." u, ". FORUMS_TABLE ." f, ". POSTS_TABLE ." p
  WHERE t.topic_id = '". $topics[$i]['topic_id'] ."'
  AND f.forum_id = t.forum_id
  AND p.topic_id = t.topic_id 
  AND u.user_id = p.poster_id
  GROUP BY t.topic_id";
 if ( !($result = $db->sql_query($sql)) )
 {
  	message_die(GENERAL_ERROR, "Could not get similar topics", '', __LINE__, __FILE__, $sql);
 }
  
  while ( $row = $db->sql_fetchrow($result) )
  {
   $similar = $row;

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
	for($i = 0; $i < $count_similar; $i++)
	{
		$similar = $similar_topics[$i];

# 
#-----[ FIND ]------------------------------------------ 
# 
   $author_url = append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $similar['user_id']);

   $author = ( $similar['user_id'] != ANONYMOUS ) ? '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $similar['user_id']) .'">'. $similar['username'] .'</a>' : ( ($similar['post_username'] != '' ) ? $similar['post_username'] : $lang['Guest'] );

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
	$author_url = append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $similar['user_id']);
	$author = ( $similar['user_id'] != ANONYMOUS ) ? '<a href="'. $author_url .'">'. $similar['username'] .'</a>' : ( ($similar['post_username'] != '' ) ? $similar['post_username'] : $lang['Guest'] );

# 
#-----[ FIND ]------------------------------------------ 
# 
   $forum_url = append_sid("viewforum.$phpEx?f=". $similar['forum_id']);  

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
		$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=". $similar['forum_id']);  

# 
#-----[ FIND ]------------------------------------------ 
# 
   $post_time = create_date($board_config['default_dateformat'], $similar['topic_time'], $board_config['board_timezone']);

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

# 
#-----[ FIND ]------------------------------------------ 
# 
    $template->assign_block_vars('similar.topics', array(

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
			 'ROW_COLOR' => '#' . $row_color,
			 'ROW_CLASS' => $row_class,

# 
#-----[ FIND ]------------------------------------------ 
# 
  } // while
 } // for $i
} // if ( $count_similar > 0 )

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
	} //for $i
}// if ( $count_similar > 0 )

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/viewtopic_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
  <td class="row1" align="center"><span class="genmed"><img src="{similar.topics.FOLDER}" border="0" alt="{similar.topics.ALT}" title="{similar.topics.ALT}" /></span></td>
  <td class="row1" width="30%">{similar.topics.NEWEST}<span class="gensmall">{similar.topics.TYPE}</span> <span class="topictitle">{similar.topics.TOPICS}</span></td>
  <td class="row1" width="10%"><span class="genmed">{similar.topics.AUTHOR}</span></td>
  <td class="row1"><span class="genmed">{similar.topics.FORUM}</span></td>
  <td class="row1" width="15%" align="center"><span class="genmed">{similar.topics.REPLIES}</span></td>
  <td class="row1"><span class="genmed">{similar.topics.POST_TIME} {similar.topics.POST_URL}</span></td>

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
  <td class="{similar.topics.ROW_CLASS}" align="center"><img src="{similar.topics.FOLDER}" border="0" alt="{similar.topics.ALT}" title="{similar.topics.ALT}" /></td>
  <td class="{similar.topics.ROW_CLASS}" width="30%">{similar.topics.NEWEST}<span class="gensmall">{similar.topics.TYPE}</span> <span class="topictitle">{similar.topics.TOPICS}</span></td>
  <td class="{similar.topics.ROW_CLASS}" width="10%"><span class="genmed">{similar.topics.AUTHOR}</span></td>
  <td class="{similar.topics.ROW_CLASS}"><span class="genmed">{similar.topics.FORUM}</span></td>
  <td class="{similar.topics.ROW_CLASS}" width="15%" align="center"><span class="genmed">{similar.topics.REPLIES}</span></td>
  <td class="{similar.topics.ROW_CLASS}"><span class="genmed">{similar.topics.POST_TIME} {similar.topics.POST_URL}</span></td>
Benutzeravatar
easygo
Mitglied
Beiträge: 2170
Registriert: 03.09.2004 13:45
Kontaktdaten:

Beitrag von easygo »

Nice way to start over here with some useful changes.

Thanks for publishing. easy
Benutzeravatar
Poruchik
Mitglied
Beiträge: 12
Registriert: 16.01.2006 21:21
Kontaktdaten:

Beitrag von Poruchik »

Hi!
I offer Extended Similar topics :grin:

Download

Description on Russian
Benutzeravatar
Poruchik
Mitglied
Beiträge: 12
Registriert: 16.01.2006 21:21
Kontaktdaten:

Beitrag von Poruchik »

Update Extended Similar Topics to 1.0.3
- fixed a bug in show of time of last post.
+ added the name of the author of last post.
+ added the translation in the German language. A special thanks to easygo!
diegoriv
Mitglied
Beiträge: 115
Registriert: 09.08.2005 10:21
Kontaktdaten:

Beitrag von diegoriv »

moved topis are shown!!!

you have to add a line to the sql-code

Code: Alles auswählen

AND t.topic_status <> " . TOPIC_MOVED . "
****************************************
Alpinum.at - Forum für Bergsteiger
****************************************
Antworten

Zurück zu „phpBB 2.0: Mod Support“