Seite 1 von 1

Smartors Album-Mod: best rated image anzeigen lassen

Verfasst: 13.02.2005 02:47
von Walter
Ich habe den Photo Album 2.0.53 Mod eingebaut und angepasst, nun hätte ich gerne noch eine Box in der Indexseite des Albums, in welcher das Bild angezeigt werden soll, das die beste Bewertung bekommen hat.

Wie mache ich das?
Vermutlich genügt es nicht, nur die album_index_body.tpl zu modifizieren, eine Tabelle hineinwursteln ist ja nicht das Problem. Das Bild ist das Problem, da ich dazu eventuell Datenbankabfragen brauche, wovon ich leider absolut keine Ahnung habe.

Im Forum von Smartor gab es bis dato leider keine Hilfe dazu.

Verfasst: 13.02.2005 14:46
von Walter
Nach einer kurzen Suche habe ich entdeckt, dass es das schon als Addon gibt. Hier zu finden:

http://www.phpbbhacks.com/download/1319

Und weil wir schon beim Modden sind - hier gibt es auch einen Fix für die Fehlermeldung, wenn man beim letzten Bild auf "weiter" klickt:

http://www.phpbbhacks.com/download/2356

Verfasst: 13.02.2005 15:42
von Walter
So, jetzt habe ich folgendes Problem:

Da ich mein Forum in ein CMS umgebaut habe, wo ausser mir niemand postet, wird in der HighestRatedPics Tabelle nur die Meldung "Keine Bilder vorhanden" angezeigt. In der RecentPics und in den Kategorien sind aber alle Bilder sichtbar.

Was muss ich da ändern?
Der Code für die HighestRatedPics ist:

Code: Alles auswählen

+----------------------------------------------------------
| Highest Rated Pics
| by MarkFulton.com
+----------------------------------------------------------
*/

if ($allowed_cat != '')
{
	$sql = "SELECT p.pic_id, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_user_ip, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_view_count, u.user_id, u.username, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments
			FROM ". ALBUM_TABLE ." AS p
				LEFT JOIN ". USERS_TABLE ." AS u ON p.pic_user_id = u.user_id
				LEFT JOIN ". ALBUM_CAT_TABLE ." AS ct ON p.pic_cat_id = ct.cat_id
				LEFT JOIN ". ALBUM_RATE_TABLE ." AS r ON p.pic_id = r.rate_pic_id
				LEFT JOIN ". ALBUM_COMMENT_TABLE ." AS c ON p.pic_id = c.comment_pic_id
			WHERE p.pic_cat_id IN ($allowed_cat) AND ( p.pic_approval = 1 OR ct.cat_approval = 0 )
			GROUP BY p.pic_id
			ORDER BY rating DESC
			LIMIT ". $album_config['cols_per_page'];
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query highest rated pics information', '', __LINE__, __FILE__, $sql);
	}

	$highestrow = array();

	while( $row = $db->sql_fetchrow($result) )
	{
		$highestrow[] = $row;
	}


	if (count($highestrow) > 0)
	{
		for ($i = 0; $i < count($highestrow); $i += $album_config['cols_per_page'])
		{
			$template->assign_block_vars('highest_pics', array());

			for ($j = $i; $j < ($i + $album_config['cols_per_page']); $j++)
			{
				if( $j >= count($highestrow) )
				{
					break;
				}

				if(!$highestrow[$j]['rating'])
				{
					$highestrow[$j]['rating'] = $lang['Not_rated'];
				}
				else
				{
					$highestrow[$j]['rating'] = round($highestrow[$j]['rating'], 2);
				}

				$template->assign_block_vars('highest_pics.highest_col', array(
					'U_PIC' => ($album_config['fullpic_popup']) ? append_sid("album_pic.$phpEx?pic_id=". $highestrow[$j]['pic_id']) : append_sid("album_page.$phpEx?pic_id=". $highestrow[$j]['pic_id']),
					'THUMBNAIL' => append_sid("album_thumbnail.$phpEx?pic_id=". $highestrow[$j]['pic_id']),
					'DESC' => $highestrow[$j]['pic_desc']
					)
				);

				if( ($highestrow[$j]['user_id'] == ALBUM_GUEST) or ($highestrow[$j]['username'] == '') )
				{
					$highest_poster = ($highestrow[$j]['pic_username'] == '') ? $lang['Guest'] : $highestrow[$j]['pic_username'];
				}
				else
				{
					$highest_poster = '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $highestrow[$j]['user_id']) .'">'. $highestrow[$j]['username'] .'</a>';
				}

				$template->assign_block_vars('highest_pics.highest_detail', array(
					'H_TITLE' => $highestrow[$j]['pic_title'],
					'H_POSTER' => $highest_poster,
					'H_TIME' => create_date($board_config['default_dateformat'], $highestrow[$j]['pic_time'], $board_config['board_timezone']),

					'H_VIEW' => $highestrow[$j]['pic_view_count'],

					'H_RATING' => ($album_config['rate'] == 1) ? ( '<a href="'. append_sid("album_rate.$phpEx?pic_id=". $highestrow[$j]['pic_id']) . '">' . $lang['Rating'] . '</a>: ' . $highestrow[$j]['rating'] . '<br />') : '',

					'H_COMMENTS' => ($album_config['comment'] == 1) ? ( '<a href="'. append_sid("album_comment.$phpEx?pic_id=". $highestrow[$j]['pic_id']) . '">' . $lang['Comments'] . '</a>: ' . $highestrow[$j]['comments'] . '<br />') : '',

					'H_IP' => ($userdata['user_level'] == ADMIN) ? $lang['IP_Address'] . ': <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . decode_ip($highestrow[$j]['pic_user_ip']) . '" target="_blank">' . decode_ip($highestrow[$j]['pic_user_ip']) .'</a><br />' : ''
					)
				);
			}
		}
	}
	else
	{
		//
		// No Pics Found
		//
		$template->assign_block_vars('no_pics', array());
	}
}
else
{
	//
	// No Cats Found
	//
	$template->assign_block_vars('no_pics', array());
}
Hat jemand eine Idee? Ich bin in PHP ein noob. :-?

Verfasst: 13.02.2005 16:37
von Walter
Ich hab den Mod an der falschen Stelle eingefügt! :oops:
Jetzt funzt es.