Seite 3 von 3

Verfasst: 16.08.2008 15:37
von Dungeonwatcher
Hi! 8)

Hmmm, PHP ist für mich nur wirre Buchstaben, da habe ich leider Null durchsicht. HTML wäre mir da lieber. 8)

Der zuständige Code dürfte dieser sein:

Code: Alles auswählen

if ( $count_similar > 0 )
{
	$template->assign_block_vars('similar', array(
		'L_SIMILAR' => $lang['Similar'],
		'L_TOPIC' => $lang['Topic'],
		'L_AUTHOR' => $lang['Author'],
		'L_FORUM' =>  $lang['Forum'],
		'L_REPLIES' => $lang['Replies'],
		'L_LAST_POST' => $lang['Posted'])
	);

	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 f.forum_id NOT IN (" . $except_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;

			$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_t']) : array();
			$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f']) : array();
			$topic_type =  ( $similar['topic_type'] == POST_ANNOUNCE ) ? $lang['Topic_Announcement'] .' ': '';
			$topic_type .= ( $similar['topic_type'] == POST_STICKY ) ? $lang['Topic_Sticky'] .' ': '';
			$topic_type .= ( $similar['topic_vote'] ) ? $lang['Topic_Poll'] .' ': '';
			$replies = $similar['topic_replies'];

			if( $similar['topic_status'] == TOPIC_LOCKED )
			{
				$folder = $images['folder_locked'];
				$folder_new = $images['folder_locked_new'];
			}
			else if( $similar['topic_type'] == POST_ANNOUNCE )
			{
				$folder = $images['folder_announce'];
				$folder_new = $images['folder_announce_new'];
			}
			else if( $similar['topic_type'] == POST_GLOBAL_ANNOUNCE )
			{
				$folder = $images['folder_global_announce'];
				$folder_new = $images['folder_global_announce_new'];
			}
			else if( $similar['topic_type'] == POST_STICKY )
			{
				$folder = $images['folder_sticky'];
				$folder_new = $images['folder_sticky_new'];
			}
			else
			{
				if( $replies >= $board_config['hot_threshold'] )
				{
					$folder = $images['folder_hot'];
					$folder_new = $images['folder_hot_new'];
				}
				else
				{
					$folder = $images['folder'];
					$folder_new = $images['folder_new'];
				}
			}
			if( $userdata['session_logged_in'] )
			{
				if( $similar['post_time'] > $userdata['user_lastvisit'] )
				{
					if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all']) )
					{
						$unread_topics = true;
						if( !empty($tracking_topics[$topic_id]) )
						{
							if( $tracking_topics[$topic_id] >= $similar['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if( !empty($tracking_forums[$forum_id]) )
						{
							if( $tracking_forums[$forum_id] >= $similar['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all']) )
						{
							if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all'] >= $similar['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if( $unread_topics )
						{
							$folder_image = $folder_new;
							$folder_alt = $lang['New_posts'];
							$newest_img = '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=$topic_id&view=newest") .'"><img src="'. $images['icon_newest_reply'] .'" alt="'. $lang['View_newest_post'] .'" title="'. $lang['View_newest_post'] .'" border="0" /></a> ';
						}
						else
						{
							$folder_image = $folder;
							$folder_alt = ( $similar['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
							$newest_img = '';
						}
					}
					else
					{
						$folder_image = $folder_new;
						$folder_alt = ( $similar['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
						$newest_img = '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=$topic_id&view=newest") .'"><img src="'. $images['icon_newest_reply'] .'" alt="'. $lang['View_newest_post'] .'" title="'. $lang['View_newest_post'] .'" border="0" /></a> ';
					}
				}
				else
				{
					$folder_image = $folder;
					$folder_alt = ( $similar['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
					$newest_img = '';
				}
			}
			else
			{
				$folder_image = $folder;
				$folder_alt = ( $similar['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
				$newest_img = '';
			}

			$title = (strlen($similar['topic_title']) > 60) ? (substr($similar['topic_title'], 0, 40) . '...') : $similar['topic_title'];
			$topic_url = '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL .'='. $similar['topic_id']) .'">'. $title . '</a>';

			$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'] );

			$forum_url = append_sid("viewforum.$phpEx?f=". $similar['forum_id']);
			$forum = '<a href="'. $forum_url .'">'. $similar['forum_name'] .'</a>';

			$post_url = '<a href="'. append_sid("viewtopic.$phpEx?". POST_POST_URL .'='. $similar['topic_last_post_id']) .'#'. $similar['topic_last_post_id'] .'"><img src="'. $images['icon_latest_reply'] .'" alt="'. $lang['View_latest_post'] .'" title="'. $lang['View_latest_post'] .'" border="0" /></a>';
			$post_time = create_date($board_config['default_dateformat'], $similar['topic_time'], $board_config['board_timezone']);

			$template->assign_block_vars('similar.topics', array(
				'FOLDER' => $folder_image,
				'ALT' => $folder_alt,
				'TYPE' => $topic_type,
				'TOPICS' => $topic_url,
				'AUTHOR' => $author,
				'FORUM' => $forum,
				'REPLIES' => $replies,
				'NEWEST' => $newest_img,
				'POST_TIME' => $post_time,
				'POST_URL' => $post_url)
				);
		}
	}
}
Wie müsste das ganze geändert werden?

THNX

Verfasst: 16.08.2008 15:54
von Gumfuzi
Ist jetzt ohne Board schwer zu testen, aber probiere es mal damit:

suche:

Code: Alles auswählen

      $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 f.forum_id NOT IN (" . $except_forum_id . ")
      AND p.topic_id = t.topic_id
      AND u.user_id = p.poster_id
      GROUP BY t.topic_id";
ersetze mit:

Code: Alles auswählen

      $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, t.topic_poster, 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 f.forum_id NOT IN (" . $except_forum_id . ")
      AND p.topic_id = t.topic_id
      AND u.user_id = t.topic_poster
      GROUP BY t.topic_id";

Verfasst: 17.08.2008 02:06
von Dungeonwatcher
Moin! 8)

Das funktioniert perfekt. THNX

Bye

Verfasst: 17.08.2008 09:22
von Gumfuzi
gerne doch!