經過測試發現, 之前的觀念錯誤!
若要使用 <iframe>, 則需要處理的地方更多.
以下的修改, 提供您參考:
#
#-----[ OPEN ]-----
#
index.php
#
#-----[ FIND ]-----
#
代碼: 選擇全部
//
// Generate the page
//
#
#-----[ BEFORE, ADD ]-----
#
代碼: 選擇全部
// + Blog News =====
//
// Get the moods data
//
$sql = "SELECT *
FROM " . WEBLOG_MOODS_TABLE . "
ORDER BY mood_text";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain mood data from database", "", __LINE__, __FILE__, $sql);
}
$mood_data = $db->sql_fetchrowset($result);
//
// Get the actions data
//
$sql = "SELECT *
FROM " . WEBLOG_ACTIONS_TABLE . "
ORDER BY action_text";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain action data from database", "", __LINE__, __FILE__, $sql);
}
$action_data = $db->sql_fetchrowset($result);
// Get the user's clearence levels
$auth_level = get_auth_level ( $weblog_data, $friends_data, $blocked_data, $weblog_data['user_id'], $contributor );
// See if user can see this weblog
if ( $weblog_data['weblog_auth'] > $auth_level )
{
message_die(GENERAL_ERROR, $lang['Weblog_noaccess']);
}
//
// Latest Entries
//
if ( $weblog_config['show_latest_entries'] )
{
$sql = "SELECT e.entry_id, e.entry_access, e.entry_subject, e.entry_time, e.entry_views, e.entry_poster_id, e.entry_text, e.bbcode_uid, e.entry_mood, e.entry_currently, e.currently_text, e.entry_replies, u.user_id, u.username
FROM " . WEBLOG_ENTRIES_TABLE . " AS e, " . USERS_TABLE . " AS u
WHERE entry_access <= $auth_level
AND e.entry_poster_id = u.user_id
AND e.entry_deleted <> " . TRUE . "
ORDER BY entry_id DESC
LIMIT " . $weblog_config['latest_entry_max'];
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query blog information', '', __LINE__, __FILE__, $sql);
}
$blogs = $db->sql_numrows($result);
$blog_row = array();
while ($row = $db->sql_fetchrow($result))
{
$blog_row[] = $row;
}
$template->assign_block_vars('switch_show_latest_entries', array());
for ($i = 0; $i < $blogs; $i++)
{
if ( $blog_row[$i]['entry_text'] )
{
$last_entry_data = $blog_row[$i];
// Mood
$mood = array();
$mood = find_mood($last_entry_data['entry_mood']);
if ( $mood >= 0 )
{
$mood = sprintf($lang['Mood:'], '<img src="images/weblogs/' . $mood['mood_url'] . '" alt="' . $mood_data['mood_text'] . '" style="vertical-align: middle" border="0" />', $mood['mood_text']);
}
else
{
$mood = $lang['None'];
}
// Currently Icons
$currently = array();
$currently = find_action($last_entry_data['entry_currently']);
if ( $currently > 0 )
{
$action = sprintf($lang['Currently:'], '<img src="images/weblogs/' . $currently['action_url'] . '" alt="' . $currently['action_text'] . ' ' . $last_entry_data['currently_text'] . '" style="vertical-align: middle" border="0" />', $currently['action_text'] . ' ' . $last_entry_data['currently_text']);
}
else if ( $last_entry_data['currently_text'] && $currently == -2 )
{
$action = sprintf($lang['Currently:'], '', $last_entry_data['currently_text']);
}
else
{
$action = '';
}
}
// Guest - show a hot folder image if number of replies exceeds hot level
$replies = $blog_row[$i]['entry_replies'];
if($replies >= $weblog_config['hot_level'])
{
$folder = $images['folder_hot'];
}
else
{
$folder = $images['folder'];
}
// User is logged in - check for new entries since last visit
// and show a hot new folder image if new entry and number of replies exceeds hot level.
// If just new entry then show the new folder image - else just show the folder image
$newest_post_img = '';
if( $userdata['session_logged_in'] )
{
if( $blog_row[$i]['entry_time'] > $userdata['user_lastvisit'] && $replies >= $weblog_config['hot_level'])
{
$folder = $images['folder_hot_new'];
$newest_post_img = '<a href="' . append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $blog_row[$i]['entry_id']) . '"><img src="' . $images['icon_newest_reply'] . '" border="0" /></a> ';
}
elseif( $blog_row[$i]['entry_time'] > $userdata['user_lastvisit'])
{
$folder = $images['folder_new'];
$newest_post_img = '<a href="' . append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $blog_row[$i]['entry_id']) . '"><img src="' . $images['icon_newest_reply'] . '" border="0" /></a> ';
}
elseif($replies >= $weblog_config['hot_level'])
{
$folder = $images['folder_hot'];
}
else
{
$folder = $images['folder'];
$newest_post_img = '';
}
}
$entry_poster = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . "u" . "=" . $blog_row[$i]['user_id']) . '">' . $blog_row[$i]['username'] . '</a>';
// Has admin enabled currently in the entry block? If yes, then adjust colspan
if ( $weblog_config['show_action'] )
{
$colspan = 2;
}
else
{
$colspan = 1;
}
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('switch_show_latest_entries.blog_row', array(
'ENTRY_FOLDER_IMG' => $folder,
'NEWEST_POST_IMG' => $newest_post_img,
'ROW_COLOR' => $row_color,
'ROW_CLASS' => $row_class,
'LATEST_MOOD' => $mood,
'U_LATEST_ENTRY' => append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $blog_row[$i]['entry_id']),
'L_LATEST_ENTRIES' => $blog_row[$i]['entry_subject'],
'L_ENTRY_TEXT' => $blog_row[$i]['entry_text'],
'L_ENTRY_REPLIES' => $blog_row[$i]['entry_replies'],
'L_VIEWS' => $blog_row[$i]['entry_views'],
'S_POSTER' => $entry_poster,
'S_POSTTIME' => create_date($board_config['default_dateformat'], $blog_row[$i]['entry_time'], $board_config['board_timezone'])
)
);
// Has admin enabled action in the entry block?
if ( $weblog_config['show_action'] )
{
$template->assign_block_vars('switch_show_latest_entries.blog_row.switch_show_action', array(
'LATEST_ACTION' => $action)
);
}
}
}
// - Blog News =====
#
#-----[ OPEN ]-----
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]-----
# ps. 僅供參考; 請自行選擇欲加入其後的區塊 (表格)
代碼: 選擇全部
<table cellspacing="3" border="0" align="center" cellpadding="0">
<tr>
<td width="20" align="center"><img src="templates/subSilver/images/folder_new_big.gif" alt="{L_NEW_POSTS}"/></td>
<td><span class="gensmall">{L_NEW_POSTS}</span></td>
<td> </td>
<td width="20" align="center"><img src="templates/subSilver/images/folder_big.gif" alt="{L_NO_NEW_POSTS}" /></td>
<td><span class="gensmall">{L_NO_NEW_POSTS}</span></td>
<td> </td>
<td width="20" align="center"><img src="templates/subSilver/images/folder_locked_big.gif" alt="{L_FORUM_LOCKED}" /></td>
<td><span class="gensmall">{L_FORUM_LOCKED}</span></td>
</tr>
</table>
#
#-----[ AFTER, ADD ]-----
#
代碼: 選擇全部
<br>
<!-- BEGIN switch_show_latest_entries -->
<table width="100%" cellspacing="1" cellpadding="5" align="center" class="forumline">
<tr>
<td colspan="7" nowrap="nowrap" class="catHead"><span class="cattitle"><a href="{U_WEBLOGS_NEWS}" title="{L_WEBLOGS_NEWS}" class="cattitle">{L_WEBLOGS_NEWS}</a></span></td>
</tr>
<tr>
<th width="3%"> </th>
<th width="47%" colspan="2">{L_LATEST_ENTRIES}</th>
<th nowrap="nowrap">{L_LATEST_MOOD}</th>
<th>{L_AUTHOR}</th>
<th>{L_VIEWS}</th>
<th>{L_LASTPOST}</th>
</tr>
<!-- BEGIN blog_row -->
<tr>
<td class="{switch_show_latest_entries.blog_row.ROW_CLASS}" align="center"><img src="{switch_show_latest_entries.blog_row.ENTRY_FOLDER_IMG}"></td>
<td class="{switch_show_latest_entries.blog_row.ROW_CLASS}" nowrap="nowrap">{switch_show_latest_entries.blog_row.NEWEST_POST_IMG}<span class="topictitle"><a href="{switch_show_latest_entries.blog_row.U_LATEST_ENTRY}">{switch_show_latest_entries.blog_row.L_LATEST_ENTRIES}</a></span><span class="genmed"> ({switch_show_latest_entries.blog_row.L_ENTRY_REPLIES} {L_REPLIES})</span>
<!-- BEGIN switch_show_action -->
<td width="20%" align="right" class="{switch_show_latest_entries.blog_row.ROW_CLASS} align="right"><span class="genmed">{switch_show_latest_entries.blog_row.switch_show_action.LATEST_ACTION}</span></td>
<!-- END switch_show_action -->
</td>
<td width="20%" class="{switch_show_latest_entries.blog_row.ROW_CLASS}" align="center"><span class="genmed">{switch_show_latest_entries.blog_row.LATEST_MOOD}</span></td>
<td width="15%" class="{switch_show_latest_entries.blog_row.ROW_CLASS}" align="center"><span class="genmed">{switch_show_latest_entries.blog_row.S_POSTER}</span></td>
<td width="10%" class="{switch_show_latest_entries.blog_row.ROW_CLASS}" align="center"><span class="genmed">{switch_show_latest_entries.blog_row.L_VIEWS}</span></td>
<td width="100" class="{switch_show_latest_entries.blog_row.ROW_CLASS}" align="center"><span class="genmed">{switch_show_latest_entries.blog_row.S_POSTTIME}</span></td>
</tr>
<!-- END blog_row -->
<tr>
<td colspan="7" class="catBottom" align="center" valign="middle" colspan="6" height="28"><span class="genmed"> </span></td>
</tr>
</table>
<!-- END switch_show_latest_entries -->
#
#-----[ SAVE & CLOSE ]-----
#
#End
DEMO:
http://wang5555.dnsfor.me/phpbb2/weblogs_news.php
http://wang5555.dnsfor.me/phpbb2/index.php