1. Đầu tiên các bạn tải file đính kèm về và giải nén
2. Upload thư mục styles và images lên thư mục gốc của diễn đàn
4. Mở file includes\functions.php
Thêm vào:
- Mã: Chọn tất cả
function is_char($chr) {
if (($chr >= 'a' && $chr <= 'z')
|| ($chr >= 'A' && $chr <= 'Z'))
{
return true;
}
return false;
}
function is_digit($chr) {
if ($chr >= '0' && $chr <= '9')
{
return true;
}
return false;
}
function is_delim($chr)
{
if ($chr == '\n'
|| $chr == '\t'
|| ($chr >= chr(32) && $chr <= chr(128) && $chr != '_' && !is_char($chr)) && !is_digit($chr))
{
return true;
}
return false;
}
/**
* Truncates string while retaining special characters if going over the max length
* The default max length is 60 at the moment
*/
function cpvn_truncate_string($string, $max_length = 60, $allow_reply = true, $append = '', $htmlspecchars_decode = true)
{
$chars = array();
$strip_reply = false;
$stripped = false;
if ($allow_reply && strpos($string, 'Re: ') === 0)
{
$strip_reply = true;
$string = substr($string, 4);
}
if ($htmlspecchars_decode) {
$string = htmlspecialchars_decode($string);
}
if (strlen($string) > $max_length) {
$string = substr($string, 0, $max_length);
$stripped = true;
}
if ($stripped)
{
$found_delim = false;
for ($i = 0; $i<8 && $i<$max_length; ++$i) {
if (is_delim($string[$max_length - $i - 1])) {
$found_delim = true;
break;
}
}
if ($found_delim) {
$string = rtrim(substr($string, 0, $max_length - $i));
}
}
if ($strip_reply)
{
$string = 'Re: ' . $string;
}
if ($append != '' && $stripped)
{
$string = $string . $append;
}
return $string;
}
5. Mở file includes\functions_display.php
Thêm vào:
- Mã: Chọn tất cả
* Display Latest Posts
*/
function display_latest_posts()
{
global $db, $user, $template, $phpEx;
//Latest Posts config
$LP_NUM_COLS = 3;
$LP_NUM_TOPICS_IN_ACOL = 10;
$latest_posts = array();
$latest_posts['col_1']['title'] = $user->lang['lp_title_1'];
$latest_posts['col_1']['forums'] = '1,2,3';
$latest_posts['col_2']['title'] = $user->lang['lp_title_2'];
$latest_posts['col_2']['forums'] = '4,5,6';
$latest_posts['col_3']['title'] = $user->lang['lp_title_3'];
$latest_posts['col_3']['forums'] = '7,8,9';
// Begin to calculate
$lp_total_width_remain = 100;
$abv_latest_posts = false;
for ($i=0; $i<$LP_NUM_COLS; ++$i) {
$lp_current_width = round($lp_total_width_remain / ($LP_NUM_COLS - $i));
$lp_col = 'col_' . ($i + 1);
$lp_forums = $latest_posts[$lp_col]['forums'];
$lp_forums_constraint = " AND f.forum_id IN ($lp_forums) ";
$sql = "SELECT f.forum_name, t.topic_title, t.topic_replies, t.topic_views, u.username, p.post_id, p.post_time
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE t.forum_id = f.forum_id
AND p.post_id = t.topic_last_post_id
AND u.user_id = p.poster_id
AND t.topic_status <> " . ITEM_MOVED . "
AND t.topic_approved = 1
$lp_forums_constraint
ORDER BY p.post_time DESC
LIMIT $LP_NUM_TOPICS_IN_ACOL";
if( !($result = $db->sql_query($sql)) )
{
trigger_error('An error occured while reading data from database for LATEST POSTS');
}
$latest_posts_rows = array();
while ($row = $db->sql_fetchrow($result))
{
$latest_posts_rows[] = $row;
}
$db->sql_freeresult($result);
if (!$abv_latest_posts) {
$template->assign_block_vars('latest_posts', array(
'LP_TITLE_0' => $user->lang['lp_title_0'],
'LP_NUM_COLS' => $LP_NUM_COLS
));
$abv_latest_posts = true;
}
$template->assign_block_vars('latest_posts.forum_col', array(
'LP_TITLE_1' => $latest_posts[$lp_col]['title'],
'COL_WIDTH' => '' . $lp_current_width,
'COL_POS' => '' . (100 - $lp_total_width_remain)
));
$lp_total_width_remain -= $lp_current_width;
for( $j = 0; $j < count($latest_posts_rows); ++$j ) {
$lp_topic_url = append_sid('viewtopic.' . $phpEx . '?p=' . $latest_posts_rows[$j]['post_id'] . '#p' . $latest_posts_rows[$j]['post_id']);
$lp_topic_title = censor_text($latest_posts_rows[$j]['topic_title']);
$lp_topic_tip =
$user->lang['lp_topic'] . ': ' . $lp_topic_title . "\n • "
. $user->lang['lp_forum'] . ': ' . $latest_posts_rows[$j]['forum_name'] . "\n • "
. $user->lang['lp_poster'] . ': ' . $latest_posts_rows[$j]["username"] . "\n • "
. $user->lang['lp_posted_dttm'] . ': ' . $user->format_date($latest_posts_rows[$j]['post_time']) . "\n • "
. $user->lang['lp_replies'] . ': ' . $latest_posts_rows[$j]['topic_replies'] . "\n • "
. $user->lang['lp_views'] . ': ' . $latest_posts_rows[$j]['topic_views'];
$template->assign_block_vars('latest_posts.forum_col.topic_row', array(
'TOPIC_TITLE' => cpvn_truncate_string($lp_topic_title, 40, false, '...', false),
'TOPIC_URL' => $lp_topic_url,
'TOPIC_TIP' => $lp_topic_tip
));
}
}
}
6. Mở file language\vi\common.php
Thêm vào file ngôn ngữ:
- Mã: Chọn tất cả
'lp_title_0' => 'Bài viết mới nhất',
'lp_title_1' => 'Tiêu đề cột 1',
'lp_title_2' => 'Tiêu đề cột 2',
'lp_title_3' => 'Tiêu đề cột 3',
'lp_title_4' => 'Tiêu đề cột 4',
'lp_topic' => 'Topic',
'lp_forum' => 'Forum',
'lp_poster' => 'Người viết',
'lp_posted_dttm' => 'Ngày viết',
'lp_replies' => 'Trả lời',
'lp_views' => 'Lần xem',
Nếu cho tiếng Anh bạn cũng làm tương tự ở file language\en\common.php
7. Mở file styles\prosilver\template\index_body.html
Thêm vào: <!-- INCLUDE latest_posts_body.html --> ở trên dòng <!-- INCLUDE forumlist_body.html -->
8. Mở file styles\prosilver\theme\content.css
Thêm vào
- Mã: Chọn tất cả
ul.latest-posts {
display: block;
float: left;
}
ul.latest-posts li.row {
border: none;
position: static;
}
ul.latest-posts li.hdrrow { background-color: #cadceb; }
ul.latest-posts li.hdrrow:hover { background-color: #cadceb; }
ul.latest-posts li.row dl.icon {
min-height: 0;
}
ul.latest-posts li.row dl.icon dt {
background: url(images/common/star.gif) center left no-repeat;
border-left: 0px solid #fff;
padding-left: 20px;
white-space: nowrap;
font-weight: bold;
font-size: 1.3em;
height: 1.3em;
}
ul.latest-posts li.row dl.icon dd {
background: url(images/common/latestpost.gif) center left no-repeat;
border: none;
padding-left: 12px;
padding-top: 1px;
padding-bottom: 0;
font-size: 1.1em;
white-space: nowrap;
height: auto;
}
9. Mở file index.php
Tìm đến dòng 125 thêm vào display_latest_posts(); ngay dưới dòng page_header($user->lang['INDEX']);
Sau khi sửa xong, vào chức năng quản trị diễn đàn. Vào mục Giao diện - > khuôn mẫu -> Nạp lại (refresh lại khuôn mẫu).
OK! Bạn hãy mở diễn đàn ra và chiêm ngưỡng thành quả do công sức của mình đã bỏ ra sau 9 công đoạn vừa rồi.
Chú ý: Bạn có thể tiến hành tương tự đối với subsilver2