[推薦]不用安裝4images 類似的相本…

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
頭像
dicks
星球公民
星球公民
文章: 40
註冊時間: 2004-08-15 19:04
聯繫:

[推薦]不用安裝4images 類似的相本…

文章 dicks »

若是已安裝 attachment 的文章附檔mod
又安裝了相片簿mod,有時會想想,二者都有上傳的功能
且又會增加了不少站的複雜度!
所以就想利用attachment的功能來達到類似相本的功能
但無法像 4images 那樣有
開放區、會員區、相本評分之類!
若不想裝那麼多的話…就試試吧!
demo 圖

代碼: 選擇全部

-------------------------------------------------------------------- 
make copy attachments.php and attachments.tpl 
then rename viewattachpic.php and viewattchpic.tpl 
# 
#-----[ OPEN ]--------------------------------------------- 
# 

viewattachpic.php 
# 
#-----[ FIND ]--------------------------------------------- 
# 
include($phpbb_root_path . 'common.'.$phpEx); 
# 
#-----[ AFTER, ADD ]--------------------------------------- 
# 
$pic_per_page=12; // picture per_page default is 12. u can set n of 4 n= 4,8,12,16... 
# 
#-----[ FIND ALL ]--------------------------------------------- 
# 
$board_config['topics_per_page'] 

# 
#-----[ REPLACE WITH ]--------------------------------------- 
# note: all about 
# $board_config['topics_per_page'] -> $pic_per_page 
$pic_per_page 

# 
#-----[ FIND ]--------------------------------------------- 
# 
attachments.tpl 

# 
#-----[ REPLACE WITH ]--------------------------------------- 
# 
viewattachpic.tpl 

#-----[ FIND ]--------------------------------------------- 
# 
if (!$forum_id && $display_all_forums) 
{ 
$sql = "SELECT a.post_id, t.topic_title, d.* 
FROM " . $attach_table . " a, " . 
WHERE (a.post_id = p.post_id) AND (p.forum_id I 
#-----[ IN-LINE FIND ]--------------------------------------------- 
# 
(a.attach_id = d.attach_id) 
#-----[ IN-LINE AFTER, ADD ]--------------------------------------- 
# 
AND (d.mimetype LIKE 'image%') 

#-----[ FIND ]--------------------------------------------- 
# 
else if (($is_auth_ary[$forum_id]['auth_read']) 
{ 
$sql = "SELECT a.post_id, t.topic_title, d.* 
FROM " . $attach_table . " a, " . $atta 
WHERE (a.post_id = p.post_id) AND (p.forum_id = " . 
#-----[ IN-LINE FIND ]--------------------------------------------- 
# 
(a.attach_id = d.attach_id) 
#-----[ IN-LINE AFTER, ADD ]--------------------------------------- 
# 
AND (d.mimetype LIKE 'image%') 
#-----[ FIND ]--------------------------------------------- 
# 
for ($i = 0; $i < $num_attachments; $i++) 
#-----[ BEFORE, ADD ]--------------------------------------- 
$k=0; 
#-----[ FIND ]--------------------------------------------- 
# note: all 
$class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 
$post_title = $attachments[$i]['topic_title']; 
$post_title_2 = ''; 

# 
#-----[ REPLACE WITH ]--------------------------------------- 
# 
if($k==0) 
{ 
\n$template->assign_block_vars('picrow', array()); 
$k=4; // how many row u want? k=? 
} 
$k--; 
$pic_name=$attachments[$i]['physical_filename']; 
$pic_url=($attachments[$i]['thumbnail'])? $upload_dir . '/' . THUMB_DIR . '/t_'. $pic_name : $upload_dir . '/' . $pic_name; 
$pic_url="<img src='".$pic_url."' border='0'>"; 
$post_title = $attachments[$i]['topic_title']; 

#-----[ FIND ]--------------------------------------------- 
# 
if (strlen($filename) > 32) 
{ 
$filename_2 = substr($filename, 0, 30) . '...'; 
} 

$view_attachment = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . intval($attachments[$i]['attach_id'])); 
if ($filename_2 != '') 
{ 
$filename_link = '<a href="' . $view_attachment . '" class="gen" title="' . $filename . '" target="_blank">' . $filename_2 . '</a>'; 
} 
else 
{ 
$filename_link = '<a href="' . $view_attachment . '" class="gen" target="_blank">' . $filename . '</a>'; 
} 
# 
#-----[ REPLACE WITH ]--------------------------------------- 
# note: all 

if (strlen($filename) > 32) // limit len of filename 
{ 
$filename = substr($filename, 0, 30) . '...'; 
} 

$view_attachment = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . intval($attachments[$i]['attach_id'])); 

#-----[ FIND ]--------------------------------------------- 
# 
$template->assign_block_vars('attachrow', array( 
'ROW_NUMBER' => $i + ( $HTTP_GET_VARS['start'] + 1 ), 
'ROW_CLASS' => $class, 

'FILENAME' => $filename, 
'COMMENT' => $comment_field, 
'SIZE' => round(($attachments[$i]['filesize'] / 1024), 2), 
'DOWNLOAD_COUNT' => $attachments[$i]['download_count'], 
'POST_TIME' => create_date($board_config['default_dateformat'], $attachments[$i]['filetime'], $board_config['board_timezone']), 
'POST_TITLE' => $post_title, 

'VIEW_ATTACHMENT' => $filename_link) 
); 
# 
#-----[ REPLACE WITH ]--------------------------------------- 
# note: all 

$template->assign_block_vars('picrow.pic', array( 
'PIC' =>$pic_url, 
'PIC_URL' => $view_attachment, 
'ROW_CLASS' => $theme['td_class2']) 
); 

$template->assign_block_vars('picrow.detail', array( 

'ROW_CLASS' => $theme['td_class1'], 
'FILENAME' => $filename, 
'COMMENT' => $comment_field, 
'SIZE' => round(($attachments[$i]['filesize'] / 1024), 2), 
'DOWNLOAD_COUNT' => $attachments[$i]['download_count'], 
'POST_TIME' => create_date($board_config['default_dateformat'], $attachments[$i]['filetime'], $board_config['board_timezone']), 
'POST_TITLE' => $post_title, 
'POST_URL' => $view_topic, 
) 
); 
#-----[ FIND ]--------------------------------------------- 
# note: around 420, second $sql = ''; 
$sql = ''; 
#-----[ BEFORE, ADD ]--------------------------------------- 

// this is make table beauty, if u don't care then make if. 
while($k) 
{ 
$template->assign_block_vars('picrow.pic', array( 

'ROW_CLASS' => $theme['td_class2'])); 
$template->assign_block_vars('picrow.detail', array( 
'ROW_CLASS' => $theme['td_class1'], 
) 

); 

$k--; 
} 
//////////////////////////////////////////////////////////////// 
# 
#-----[ FIND ]--------------------------------------------- 
# 
attachments.$phpEx?mode 
# 
#-----[ REPLACE WITH ]--------------------------------------- 
# 
viewattachpic.$phpEx?mode 

# 
#-----[ OPEN ]--------------------------------------------- 
# 
viewattachpic.tpl 

# 
#-----[ FIND ]--------------------------------------------- 
# 
<tr> 
<th height="25" class="thCornerL" nowrap="nowrap">#</th> 
<th class="thTop" nowrap="nowrap">{L_FILENAME}</th> 
<th class="thTop" nowrap="nowrap">{L_FILECOMMENT}</th> 
<th class="thTop" nowrap="nowrap">{L_SIZE}</th> 
<th class="thTop" nowrap="nowrap">{L_DOWNLOADS}</th> 
<th class="thTop" nowrap="nowrap">{L_POST_TIME}</th> 
<th class="thCornerR" nowrap="nowrap">{L_POSTED_IN_TOPIC}</th> 
</tr> 

<!-- BEGIN attachrow --> 
<tr> 
<td class="{attachrow.ROW_CLASS}" align="center"><span class="gen"> {attachrow.ROW_NUMBER} </span></td> 
<td class="{attachrow.ROW_CLASS}" align="center"><span class="gen">{attachrow.VIEW_ATTACHMENT}</span></td> 
<td class="{attachrow.ROW_CLASS}" align="center"><span class="gen"><b>{attachrow.COMMENT}</b></span></td> 
<td class="{attachrow.ROW_CLASS}" align="center" valign="middle"><span class="gen"><b>{attachrow.SIZE}</b></span></td> 
<td class="{attachrow.ROW_CLASS}" align="center" valign="middle"><span class="gen"><b>{attachrow.DOWNLOAD_COUNT}</b></span></td> 
<td class="{attachrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{attachrow.POST_TIME}</span></td> 
<td class="{attachrow.ROW_CLASS}" align="center" valign="middle"><span class="gen">{attachrow.POST_TITLE}</span></td> 
</tr> 
<!-- END attachrow --> 
<tr> 
<td class="catbottom" colspan="8" height="28"> </td> 
</tr> 

# 
#-----[ REPLACE WITH ]--------------------------------------- 
# note: all 

<tr> 
<td class="catbottom" colspan="4" height="28"> </td> 
</tr> 
<!-- BEGIN picrow --> 
<tr> 
<!-- BEGIN pic --> 
<td class="{picrow.pic.ROW_CLASS}" align="center" width="25%"> 
<a href="{picrow.pic.PIC_URL}" target="_blank">{picrow.pic.PIC}</a> 
</td> 
<!-- END pic --> 
<tr> 
<!-- BEGIN detail --> 
<td class="{picrow.detail.ROW_CLASS}" valign="top"> 
<span class="gen"> 
{L_FILENAME}:{picrow.detail.FILENAME}<br> 
{L_FILECOMMENT}:{picrow.detail.COMMENT}<br> 
{L_SIZE}:{picrow.detail.SIZE}<br> 
{L_DOWNLOADS}:{picrow.detail.DOWNLOAD_COUNT}<br> 
{L_POST_TIME}:{picrow.detail.POST_TIME}<br> 
{L_POSTED_IN_TOPIC}:<a href="{picrow.detail.POST_URL}" class="topictitle">{picrow.detail.POST_TITLE}</a></span> 
</td> 
<!-- END detail --> 
</tr> 
<!-- END picrow --> 
<tr> 
<td class="catbottom" colspan="4" height="28"> </td> 
</tr> 


# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
對了,以上要安裝view_attachments_v102 (就是看附檔的)這個mod
基本上本程式也是利用view_attachments_v102來修改成的。
tony2000
星球普通子民
星球普通子民
文章: 11
註冊時間: 2005-01-19 15:39
聯繫:

文章 tony2000 »

view_attachments_v102是不是那个付费浏览的MOD呢?
PHPBB中国,提供PHPBB各类支持及免费空间。
http://www.phpbb.cn
主題已鎖定

回到「外掛問題討論」