1 頁 (共 1 頁)

[問題]增加EZPORTAL的功能

發表於 : 2005-04-12 00:35
masakasu
問題外掛:ezportal_v218b
參考連結:略\r
使用版本:phpBB 2.0.11
網站位置:http://mba.nccu.edu.tw/~yylee/forum/portal.php
狀況描述:
各位先進:
在EZPORTAL中,可以增加一個叫做Recent Topics Block的區塊,安裝的方法如下:

代碼: 選擇全部

################################################################# 
## Title: Recent Topics Block for Smartor's ezPortal
## Author: Smartor <smartor_xp@hotmail.com> - http://smartor.is-root.com
## Description: This file explains you how to create Recent Topics block on ezPortal
##
## Files To Edit: 3
##	portal.php
##	templates/subSilver/portal_body.tpl
##	language/lang_english/lang_main.php
##
## Included Files: N/A
##
################################################################# 

#
#-----[ OPEN ]-------------------------------------------------------
#
portal.php

#
#-----[ FIND: in configuration section ]-------------------
#
// Poll Forum ID: separate by comma for multi-forums, eg. '3,8,14'
$CFG['poll_forum'] = '1';

#
#-----[ AFTER ADD ]---------------------------------------
# You could config it as well
#
// Number of Recent Topics (not Forum ID)
$CFG['number_recent_topics'] = '10';

// Excluding forums for Recent Topics, eg. '2,4,10' (note: my Recent Topics script has its own permission checking, so you can leave this variable blank)
$CFG['exceptional_forums'] = '';

#
#-----[ FIND ]---------------------------------------------
#
else
{
	$l_total_user_s = $lang['Registered_users_total'];
}

#
#-----[ AFTER ADD ]---------------------------------------
#
//
// Recent Topics
//
$sql = "SELECT * FROM ". FORUMS_TABLE . " ORDER BY forum_id";
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
}
$forum_data = array();
while( $row = $db->sql_fetchrow($result) )
{
	$forum_data[] = $row;
}

$is_auth_ary = array();
$is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata, $forum_data);

if( $CFG['exceptional_forums'] == '' )
{
	$except_forum_id = '\'start\'';
}
else
{
	$except_forum_id = $CFG['exceptional_forums'];
}

for ($i = 0; $i < count($forum_data); $i++)
{
	if ((!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_read']) or (!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_view']))
	{
		if ($except_forum_id == '\'start\'')
		{
			$except_forum_id = $forum_data[$i]['forum_id'];
		}
		else
		{
			$except_forum_id .= ',' . $forum_data[$i]['forum_id'];
		}
	}
}
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
		FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u
		WHERE t.forum_id NOT IN (" . $except_forum_id . ")
			AND t.topic_status <> 2
			AND p.post_id = t.topic_last_post_id
			AND p.poster_id = u.user_id
		ORDER BY p.post_id DESC
		LIMIT " . $CFG['number_recent_topics'];
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, 'Could not query recent topics information', '', __LINE__, __FILE__, $sql);
}
$number_recent_topics = $db->sql_numrows($result);
$recent_topic_row = array();
while ($row = $db->sql_fetchrow($result))
{
	$recent_topic_row[] = $row;
}
for ($i = 0; $i < $number_recent_topics; $i++)
{
	$template->assign_block_vars('recent_topic_row', array(
		'U_TITLE' => append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#' .$recent_topic_row[$i]['post_id'],
		'L_TITLE' => $recent_topic_row[$i]['topic_title'],
		'U_POSTER' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $recent_topic_row[$i]['user_id']),
		'S_POSTER' => $recent_topic_row[$i]['username'],
		'S_POSTTIME' => create_date($board_config['default_dateformat'], $recent_topic_row[$i]['post_time'], $board_config['board_timezone'])
		)
	);
}
//
// END - Recent Topics
//

#
#-----[ FIND ]---------------------------------------------
#
	'L_VOTE_BUTTON' => $lang['Vote'],

#
#-----[ AFTER ADD ]----------------------------------------
#
	// Recent Topics
	'L_RECENT_TOPICS' => $lang['Recent_topics'],


#
#-----[ OPEN ]-------------------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]---------------------------------------------
#
$lang['No_poll'] = 'No poll at the moment';

#
#-----[ AFTER ADD ]----------------------------------------
#
$lang['Recent_topics'] = 'Recent topics'; // Recent Topics


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

#
#-----[ FIND ]---------------------------------------------
#
		  <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
		   <tr>
			<td class="catHead" height="25"><span class="genmed"><b>{L_STATISTICS}</b></span></td>
		   </tr>
		   <tr>
			<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS}<br />{NEWEST_USER}<br /><br/>{TOTAL_POSTS} {TOTAL_TOPICS}<br />&nbsp;</span></td>
		   </tr>
		  </table>
		  
		  <br />

#
# Classical Version (if scrolling did not work you could try this)
#-----[ OR ]------------------
#
	  <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
	   <tr>
		<td class="catHead" height="25"><span class="genmed"><b>{L_RECENT_TOPICS}</b></span></td>
	   </tr>
	   <tr>
		<td class="row1" align="left"><span class="gensmall">
		<!-- BEGIN recent_topic_row -->
		&raquo; <a href="{recent_topic_row.U_TITLE}">{recent_topic_row.L_TITLE}</a><br />
		by <a href="{recent_topic_row.U_POSTER}">{recent_topic_row.S_POSTER}</a> on {recent_topic_row.S_POSTTIME}<br /><br />
		<!-- END recent_topic_row -->
		</span></td>
	   </tr>
	  </table>
	  
	  <br />

#
#-----[ SAVE/UPLOAD ALL FILES ]------------------------------------------ 
#
這個區塊可以顯示最近發表或回應的主題,但是只能顯示主題名稱、作者與發表時間,例如:
圖檔
現在我希望他也能顯示主題所在的版面名稱,不知道有沒有先進可以教我如何修改程式碼讓他有這項功能,謝謝。

發表於 : 2005-04-13 23:14
~倉木麻衣~
HI~風吹的會員您好 :mrgreen:
這個問題其實只要在SQL查詢時多加幾行並設定好傳遞的值就行了
底下是根據您提供的MOD做修改的~在phpMyAdmin裡的摸擬是OK的
試看看吧~

代碼: 選擇全部

#
#--------[ OPEN ]----------------
#
portal.php

#
#--------[ FIND ]----------------
#
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id,

#
#--------[ IN-LINE FIND ]----------------
#
u.username

#
#--------[ IN-LINE AFTER ADD ]----------------
#
,f.forum_name

#
#--------[ FIND ]----------------
#
USERS_TABLE . " AS u

#
#--------[ IN-LINE AFTER ADD ]----------------
#
, " . FORUMS_TABLE . " AS f

#
#--------[ FIND ]----------------
#
			AND p.poster_id = u.user_id 

#
#--------[ AFTER ADD ]----------------
#
			AND f.forum_id = t.forum_id 

#
#--------[ FIND ]----------------
#
		'L_TITLE' => $recent_topic_row[$i]['topic_title'],

#
#--------[ AFTER ADD ]----------------
#
		'U_FORUMS' => append_sid("viewforum.$phpEx?f=" . $recent_topic_row[$i]['forum_id']),
		'L_FORUMS' => $recent_topic_row[$i]['forum_name'],

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

#
#--------[ FIND ]----------------
#
{recent_topic_row.L_TITLE}</a><br /> 

#
#--------[ AFTER ADD ]----------------
#
		on <a href="{recent_topic_row.U_FORUMS}">{recent_topic_row.L_FORUMS}</a><br />

#
#--------[ SAVE/CLOSE ALL FILES ]----------------
#
# EoM
版面名稱要顯示在何處~您可以自行決定
重點在於要將版面相關的樣版變數放置在底下的區塊裡\r
<!-- BEGIN recent_topic_row -->
<!-- END recent_topic_row -->

發表於 : 2005-04-14 15:52
masakasu
真是太感謝~倉木麻衣~了
感謝你的熱心幫忙 :-P

但是後來出現錯誤訊息


代碼:

代碼: 選擇全部

Parse error: parse error, expecting `')'' in /home/yylee/public_html/forum/portal.php on line 187
出問題的前後幾行程式碼:

代碼: 選擇全部

$template->assign_block_vars('recent_topic_row', array(
'U_TITLE' => append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#' .$recent_topic_row[$i]['post_id'],
'L_TITLE' => $recent_topic_row[$i]['topic_title'],
'U_FORUMS' => append_sid("viewforum.$phpEx?f=" .$recent_topic_row[$i]['forum_id']),
'L_FORUMS' => $recent_topic_row[$i]['forum_name'],
'U_POSTER' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $recent_topic_row[$i]['user_id']),
'S_POSTER' => $recent_topic_row[$i]['username'],
'S_POSTTIME' => create_date($board_config['default_dateformat'], $recent_topic_row[$i]['post_time'], $board_config['board_timezone'])
		)

第187行是:

代碼: 選擇全部

 'L_FORUMS' => $recent_topic_row[$i]['forum_name'],

可以幫我看看一下嗎?謝謝喔!!

發表於 : 2005-04-14 16:56
khc
是不是你語法打錯啦,我就可以
http://www.pentaxfans.net/board

發表於 : 2005-04-14 17:20
~倉木麻衣~
嗯~
我也是覺得怪怪的@@~
左看右看也看不出有那個地方錯了@@"
如果還是不行的話~
那~先試看看把底下那行拿掉~
先確認一下是U_FORUMS有問題還是L_FORUMS有問題
這樣只差在recent topic的地方連不到版面而已\r
'U_FORUMS' => append_sid("viewforum.$phpEx?f=" .$recent_topic_row[$i]['forum_id']),

發表於 : 2005-04-15 08:58
masakasu
成功啦!!!
感謝~倉木麻衣~的大力協助以及khc的提醒
謝謝你們!!

另外請教一下khc大大,貴版首頁上的功能都是ezPortal做出來的嗎?
請教一下熱門看版的作法...
另外,首頁上顯示的最近幾篇文章或公告要怎麼作呢??
謝謝!!

發表於 : 2005-04-15 09:08
寒冰軒
您的查看誰在線上和登入的區塊中間少了一個<br />
沒有間隔
是故意的嗎?
應該算是我雞婆吧~ 呵呵

發表於 : 2005-04-16 00:56
masakasu
多謝寒冰軒大大
改過來了,呵呵!!