Random Pics on Index
Verfasst: So 04.Dez, 2005 17:35
Gefunden habe ich folgendes Snippet:
Hab den entsprechenden Code dann in die index.php, sowie index.body.tpl eingebaut.
Leider funkt das offensichtlich nicht so einfach. Verbaut ist bei mit das Full Album Pck 1.0.3.
Hat jemand eine Idee?
Code: Alles auswählen
##############################################################
## MOD Title: Random Pictures
## MOD Author: Original 'Recent Pics' Code by Smartor < smartor_xp@hotmail.com >
## Modded by CLowN
## MOD Description:
## Shows random pictures underneath your recent uploaded pics
##
## MOD Requirements: Album version 2 by Smartor ( http://smartor.is-root.com )
##
## Author Recomendations: Highest Rated Pics by MarkFulton.com
##
## Installation Level: easy
## Installation Time: 2-3 minutes
##
## Files To Edit: 2
## album.php
## templates/ YOUR TEMPLET HERE /album_index_body.tpl
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]-------------------------------------------------------
#
album.php
#
#-----[ FIND ]-------------------------------------------------------
#
/*
+----------------------------------------------------------
| Start output the page
+----------------------------------------------------------
*/
#
#-----[ BEFORE, ADD ]-------------------------------------------------------
#
/*
+----------------------------------------------------------
| Random Pictures
| by CLowN
+----------------------------------------------------------
*/
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 RAND()
LIMIT ". $album_config['cols_per_page'];
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query rand pics information', '', __LINE__, __FILE__, $sql);
}
$randrow = array();
while( $row = $db->sql_fetchrow($result) )
{
$randrow[] = $row;
}
if (count($randrow) > 0)
{
for ($i = 0; $i < count($randrow); $i += $album_config['cols_per_page'])
{
$template->assign_block_vars('rand_pics', array());
for ($j = $i; $j < ($i + $album_config['cols_per_page']); $j++)
{
if( $j >= count($randrow) )
{
break;
}
if(!$randrow[$j]['rating'])
{
$randrow[$j]['rating'] = $lang['Not_rated'];
}
else
{
$randrow[$j]['rating'] = round($randrow[$j]['rating'], 2);
}
$template->assign_block_vars('rand_pics.rand_col', array(
'U_PIC' => ($album_config['fullpic_popup']) ? append_sid("album_pic.$phpEx?pic_id=". $randrow[$j]['pic_id']) : append_sid("album_page.$phpEx?pic_id=". $randrow[$j]['pic_id']),
'THUMBNAIL' => append_sid("album_thumbnail.$phpEx?pic_id=". $randrow[$j]['pic_id']),
'DESC' => $randrow[$j]['pic_desc']
)
);
if( ($randrow[$j]['user_id'] == ALBUM_GUEST) or ($randrow[$j]['username'] == '') )
{
$rand_poster = ($randrow[$j]['pic_username'] == '') ? $lang['Guest'] : $randrow[$j]['pic_username'];
}
else
{
$rand_poster = '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $randrow[$j]['user_id']) .'">'. $randrow[$j]['username'] .'</a>';
}
$template->assign_block_vars('rand_pics.rand_detail', array(
'TITLE' => $randrow[$j]['pic_title'],
'POSTER' => $rand_poster,
'TIME' => create_date($board_config['default_dateformat'], $randrow[$j]['pic_time'], $board_config['board_timezone']),
'VIEW' => $randrow[$j]['pic_view_count'],
'RATING' => ($album_config['rate'] == 1) ? ( '<a href="'. append_sid("album_rate.$phpEx?pic_id=". $randrow[$j]['pic_id']) . '">' . $lang['Rating'] . '</a>: ' . $randrow[$j]['rating'] . '<br />') : '',
'COMMENTS' => ($album_config['comment'] == 1) ? ( '<a href="'. append_sid("album_comment.$phpEx?pic_id=". $randrow[$j]['pic_id']) . '">' . $lang['Comments'] . '</a>: ' . $randrow[$j]['comments'] . '<br />') : '',
'IP' => ($userdata['user_level'] == ADMIN) ? $lang['IP_Address'] . ': <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . decode_ip($randrow[$j]['pic_user_ip']) . '" target="_blank">' . decode_ip($randrow[$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());
}
#
#-----[ OPEN ]-------------------------------------------------------
#
templates/ YOUR TEMPLET HERE /album_index_body.tpl
#
#-----[ FIND ]-------------------------------------------------------
#
<!-- BEGIN switch_user_logged_out -->
#
#-----[ BEFORE, ADD ]-------------------------------------------------------
#
<p />
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<th class="thTop" height="25" colspan="{S_COLS}" nowrap="nowrap">Random Pictures</th>
</tr>
<!-- BEGIN no_pics -->
<tr>
<td class="row1" align="center" colspan="{S_COLS}" height="50"><span class="gen">{L_NO_PICS}</span></td>
</tr>
<!-- END no_pics -->
<!-- BEGIN rand_pics -->
<tr>
<!-- BEGIN rand_col -->
<td class="row1" width="{S_COL_WIDTH}" align="center"><a href="{rand_pics.rand_col.U_PIC}" {TARGET_BLANK}><img src="{rand_pics.rand_col.THUMBNAIL}" border="0" alt="{rand_pics.rand_col.DESC}" title="{rand_pics.rand_col.DESC}" vspace="10" /></a></td>
<!-- END rand_col -->
</tr>
<tr>
<!-- BEGIN rand_detail -->
<td class="row2"><span class="gensmall">{L_PIC_TITLE}: {rand_pics.rand_detail.TITLE}<br />
{L_POSTER}: {rand_pics.rand_detail.POSTER}<br />{L_POSTED}: {rand_pics.rand_detail.TIME}<br />
{L_VIEW}: {rand_pics.rand_detail.VIEW}<br />{rand_pics.rand_detail.RATING}{rand_pics.rand_detail.COMMENTS}{rand_pics.rand_detail.IP}</span>
</td>
<!-- END rand_detail -->
</tr>
<!-- END rand_pics -->
</table>
#
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------------------------------
#
# EoFLeider funkt das offensichtlich nicht so einfach. Verbaut ist bei mit das Full Album Pck 1.0.3.
Hat jemand eine Idee?