[phpbb]簡易子版面-首頁資訊修改法

網站架設,免費空間申請,架站技術交流區

ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

[phpbb]簡易子版面-首頁資訊修改法

文章ETERNAL » 2005-04-02 2:47 pm

1.讓子版面跟主版的主題與文章數一起計算
2.讓子版的新文章出現在首頁上
2.如圖
圖檔
圖檔

在同一區內真正的新文章應該是子分區
但是在首頁上的最新文章不是顯示子分區內的





---------------------------------------------------------
新增一個欄位main_sub
代碼: 選擇全部
ALTER TABLE `phpbb_forums` ADD `main_sub` smallint( 50 ) UNSIGNED DEFAULT '0' NOT NULL;


打開
/admin/admin_forums.php

尋找
代碼: 選擇全部
$sql = "SELECT cat_id,forum_id,forum_name,sort_sub,forum_sub from ".FORUMS_TABLE."  ORDER BY cat_id,forum_order";


替換成
代碼: 選擇全部
$sql = "SELECT cat_id,forum_id,forum_name,sort_sub,forum_sub,main_sub from ".FORUMS_TABLE."  ORDER BY cat_id,forum_order";


尋找
代碼: 選擇全部
$forum_sub[$row['forum_sub']][] = "add_select('".$row[cat_id].",".$row[forum_id].",".$row[sort_sub]."','".$row[forum_name]."','$s',".($row[sort_sub]+1).");";


替換成
代碼: 選擇全部
$forum_sub[$row['forum_sub']][] = "add_select('".$row[cat_id].",".$row[forum_id].",".$row[sort_sub].",".$row[main_sub]."','".$row[forum_name]."','$s',".($row[sort_sub]+1).");";


尋找
代碼: 選擇全部
$sub_list .="add_select('".$cat_id.",0,0','".$cat_data[$i][cat_title]."','$s',0);";

替換成
代碼: 選擇全部
$sub_list .="add_select('".$cat_id.",0,0,0','".$cat_data[$i][cat_title]."','$s',0);";


尋找
代碼: 選擇全部
$sub_list .= "add_select('".$forum_data[$cat_id][$j][cat_id].",".$forum_data[$cat_id][$j][forum_id].",".$forum_data[$cat_id][$j][sort_sub]."','".$forum_data[$cat_id][$j][forum_name]."','$s',".($forum_data[$cat_id][$j][sort_sub]+1).");";


替換成
代碼: 選擇全部
$sub_list .= "add_select('".$forum_data[$cat_id][$j][cat_id].",".$forum_data[$cat_id][$j][forum_id].",".$forum_data[$cat_id][$j][sort_sub].",".$forum_data[$cat_id][$j][forum_id]."','".$forum_data[$cat_id][$j][forum_name]."','$s',".($forum_data[$cat_id][$j][sort_sub]+1).");";


尋找
代碼: 選擇全部
            $c=intval($temp[0]);
            $forum_sub=intval($temp[1]);


後面加上
代碼: 選擇全部
            $main_sub=intval($temp[3]);


尋找
代碼: 選擇全部
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status,forum_sub,sort_sub,


在同一行的sort_sub,後面加上
代碼: 選擇全部
main_sub,


尋找
代碼: 選擇全部
VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . $c . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " .$forum_sub.",".$sort_sub.",".


在同一行的.$sort_sub.",".後面加上
代碼: 選擇全部
$main_sub.",".


尋找
代碼: 選擇全部
               if(intval($temp[1])>0)
               {
                  $sort_sub=intval($temp[2])+1;
               }else
               {
                  $sort_sub=intval($temp[2]);
               }


後面加上
代碼: 選擇全部
   $main_sub=intval($temp[3]);


尋找
代碼: 選擇全部
   ,forum_sub=".$forum_sub.",sort_sub=".$sort_sub."


後面加上
代碼: 選擇全部
,main_sub=".$main_sub."


打開
index.php

尋找
代碼: 選擇全部
   $forum_sub2 = array();


後面加上
代碼: 選擇全部
   $forum_main = array();
   $temp_forum_id=0;


尋找
代碼: 選擇全部
            $forum_sub[$row['forum_sub']][$row['forum_id']]='<a href='.append_sid('viewforum.'.$phpEx.'?' . POST_FORUM_URL .'='.$row['forum_id']).'>'. $row['forum_name'] . ' </a>';
         }
         $forum_sub2[$row['forum_sub']][]=$row[forum_id];
      }


後面加上
代碼: 選擇全部
      if($row['main_sub']==0)
      {
         $row['main_sub']=$row['forum_id'];
      }
      $forum_main[$row['main_sub']]['forum_posts']=$forum_main[$row['main_sub']]['forum_posts']+$row['forum_posts'];
      $forum_main[$row['main_sub']]['forum_topics']=$forum_main[$row['main_sub']]['forum_topics']+$row['forum_topics'];
      if($forum_main[$row['main_sub']]['post_time'] < $row['post_time'])
      {
         $forum_main[$row['main_sub']]['post_time']=$row['post_time'];
         $forum_main[$row['main_sub']]['post_username']=$row['post_username'];
         $forum_main[$row['main_sub']]['username']=$row['username'];
         $forum_main[$row['main_sub']]['user_id']=$row['user_id'];
         $forum_main[$row['main_sub']]['topic_title']=$row['topic_title'];
         $forum_main[$row['main_sub']]['forum_last_post_id']=$row['forum_last_post_id'];
      }



尋找
代碼: 選擇全部
   if ( $forum_data[$j]['forum_last_post_id'] )



代碼: 選擇全部
$forum_data[$j]['forum_last_post_id']

一直到
代碼: 選擇全部
   }
                     else
                     {
                        $last_post = $lang['No_Posts'];
                     }

把裡面所有的
$forum_data[$j]改成$forum_main[$forum_id]

尋找
代碼: 選擇全部
      'POSTS' => $forum_data[$j]['forum_posts'],
                        'TOPICS' => $forum_data[$j]['forum_topics'],


改成
代碼: 選擇全部
      'POSTS' => $forum_main[$forum_id]['forum_posts'],
                        'TOPICS' => $forum_main[$forum_id]['forum_topics'],


PS1 :

//
// Define appropriate SQL
//
switch(SQL_LAYER)
{
.............................
}

在上面的sql敘述中select版面資料時,若沒有使用
代碼: 選擇全部
,substring(pt.topic_title,1,18) as topic_title

或者as後面的變數與我的定義不同時
請自行修改或刪除
代碼: 選擇全部
$forum_main[$row['main_sub']]['topic_title']=$row['topic_title'];

phpbb的預設值沒有
代碼: 選擇全部
,substring(pt.topic_title,1,18) as topic_title


PS2:

修改完後,記得到phpbb的後台重新設定子版面
否則功能無法生效



最後由 ETERNAL 於 2005-07-08 5:39 pm 編輯,總共編輯了 1 次。

訪客
 

文章訪客 » 2005-04-08 3:06 pm

請問一下喔
最後這個PS1 我不太懂
附上我那段語法 可以指點我一下嗎
代碼: 選擇全部
//
   // Define appropriate SQL
   //
   switch(SQL_LAYER)
   {
      case 'postgresql':
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
            FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
            WHERE p.post_id = f.forum_last_post_id
               AND u.user_id = p.poster_id 
               UNION (
                  SELECT f.*, NULL, NULL, NULL, NULL
                  FROM " . FORUMS_TABLE . " f
                  WHERE NOT EXISTS (
                     SELECT p.post_time
                     FROM " . POSTS_TABLE . " p
                     WHERE p.post_id = f.forum_last_post_id 
                  )
               )
               ORDER BY cat_id, forum_order";
         break;

      case 'oracle':
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
            FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
            WHERE p.post_id = f.forum_last_post_id(+)
               AND u.user_id = p.poster_id(+)
            ORDER BY f.cat_id, f.forum_order";
         break;

      default:
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_title, t.topic_last_post_id " .
         " FROM ((( " . FORUMS_TABLE . " f " .
         " LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )" .
         " LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) " .
         " LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id ) " .
         " ORDER BY f.cat_id, f.forum_order";
      break;
   }





ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-04-08 4:30 pm

代碼: 選擇全部
t.topic_title跟substring(pt.topic_title,1,18) as topic_title
意思是一樣的,多了substring(pt.topic_title,1,18)表示只抓取前18個字

所以你可以不用改PS1的內容


最後由 ETERNAL 於 2005-04-14 11:48 pm 編輯,總共編輯了 1 次。

YuanYu
 

文章YuanYu » 2005-04-14 11:08 pm

小弟照這篇文章改了之後文章總數可顯示於首頁
在子分區的最新回覆也會顯示在首頁上不過標題卻不是子分區的
而是版面裡的標題

ps1及ps2沒改

請問題哪出了問題呢?

謝謝
http://www.fountain-pen-zone.com/phpbb/




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-04-14 11:50 pm

YuanYu 寫:小弟照這篇文章改了之後文章總數可顯示於首頁
在子分區的最新回覆也會顯示在首頁上不過標題卻不是子分區的
而是版面裡的標題

ps1及ps2沒改

請問題哪出了問題呢?

謝謝
http://www.fountain-pen-zone.com/phpbb/


PS2:
重新設定子版面



yuanyu
 

文章yuanyu » 2005-04-15 12:19 am

不好意思已重新設定子版面

現在文章數可以顯示於首頁

但是在子分區的新回覆文章,標題卻不會顯示在首頁
請問是哪邊有問題?
附上index.php
代碼: 選擇全部
<?php
/***************************************************************************
 *                                index.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: index.php,v 1.99.2.3 2004/07/11 16:46:15 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
include_once($phpbb_root_path.'includes/functions_color_groups.'.$phpEx);
color_groups_setup_list();

$viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;

if( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
   $mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
else
{
   $mark_read = '';
}

//
// Handle marking posts
//
if( $mark_read == 'forums' )
{
   if( $userdata['session_logged_in'] )
   {
      setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
   }

   $template->assign_vars(array(
      "META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("index.$phpEx") . '">')
   );

   $message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a> ');

   message_die(GENERAL_MESSAGE, $message);
}
//
// End handle marking posts
//

$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();

//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_topics = get_db_stat('topiccount');
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];

if( $total_topics == 0 )
{
   $l_total_topic_s = $lang['Posted_topics_zero_total'];
}
else if( $total_topics == 1 )
{
   $l_total_topic_s = $lang['Posted_topic_total'];
}
else
{
   $l_total_topic_s = $lang['Posted_topics_total'];
}
if( $total_posts == 0 )
{
   $l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if( $total_posts == 1 )
{
   $l_total_post_s = $lang['Posted_article_total'];
}
else
{
   $l_total_post_s = $lang['Posted_articles_total'];
}

if( $total_users == 0 )
{
   $l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
   $l_total_user_s = $lang['Registered_user_total'];
}
else
{
   $l_total_user_s = $lang['Registered_users_total'];
}


//
// Start page proper
//
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
   FROM " . CATEGORIES_TABLE . " c
   ORDER BY c.cat_order";
if( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}

$category_rows = array();
while( $category_rows[] = $db->sql_fetchrow($result) );
$db->sql_freeresult($result);

if( ( $total_categories = count($category_rows) ) )
{
   //
   // Define appropriate SQL
   //
   switch(SQL_LAYER)
   {
      case 'postgresql':
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
            FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
            WHERE p.post_id = f.forum_last_post_id
               AND u.user_id = p.poster_id 
               UNION (
                  SELECT f.*, NULL, NULL, NULL, NULL
                  FROM " . FORUMS_TABLE . " f
                  WHERE NOT EXISTS (
                     SELECT p.post_time
                     FROM " . POSTS_TABLE . " p
                     WHERE p.post_id = f.forum_last_post_id 
                  )
               )
               ORDER BY cat_id, forum_order";
         break;

      case 'oracle':
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
            FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
            WHERE p.post_id = f.forum_last_post_id(+)
               AND u.user_id = p.poster_id(+)
            ORDER BY f.cat_id, f.forum_order";
         break;

      default:
         $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_title, t.topic_id
            FROM ((( " . FORUMS_TABLE . " f
            LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
            LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id )
            LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
            ORDER BY f.cat_id, f.forum_order";
         break;
   }
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
   }

   $forum_data = array();
$forum_sub = array();
   $forum_sub2 = array();
$forum_main = array();
   $temp_forum_id=0;
   while( $row = $db->sql_fetchrow($result) )
   {
      $forum_data[] = $row;
if($row[forum_sub]>0)
      {
         if ( $row['forum_status'] == FORUM_LOCKED )
         {
            $forum_sub[$row['forum_sub']][$row['forum_id']] = '<a href='.append_sid('viewforum.'.$phpEx.'?' . POST_FORUM_URL .'='.$row['forum_id']).'>'. $row['forum_name'] . ' </a><img src="images/icon_minipost_lock.gif" alt="'.$lang['Forum_locked'].'" border="0">';
         }else
         {
            $forum_sub[$row['forum_sub']][$row['forum_id']]='<a href='.append_sid('viewforum.'.$phpEx.'?' . POST_FORUM_URL .'='.$row['forum_id']).'>'. $row['forum_name'] . ' </a>';
         }
         $forum_sub2[$row['forum_sub']][]=$row[forum_id];
      }
if($row['main_sub']==0)
      {
         $row['main_sub']=$row['forum_id'];
      }
      $forum_main[$row['main_sub']]['forum_posts']=$forum_main[$row['main_sub']]['forum_posts']+$row['forum_posts'];
      $forum_main[$row['main_sub']]['forum_topics']=$forum_main[$row['main_sub']]['forum_topics']+$row['forum_topics'];
      if($forum_main[$row['main_sub']]['post_time'] < $row['post_time'])
      {
         $forum_main[$row['main_sub']]['post_time']=$row['post_time'];
         $forum_main[$row['main_sub']]['post_username']=$row['post_username'];
         $forum_main[$row['main_sub']]['username']=$row['username'];
         $forum_main[$row['main_sub']]['user_id']=$row['user_id'];
         $forum_main[$row['main_sub']]['topic_title']=$row['topic_title'];
         $forum_main[$row['main_sub']]['forum_last_post_id']=$row['forum_last_post_id'];
      }
   }
   $db->sql_freeresult($result);

   if ( !($total_forums = count($forum_data)) )
   {
      message_die(GENERAL_MESSAGE, $lang['No_forums']);
   }

   //
   // Obtain a list of topic ids which contain
   // posts made since user last visited
   //
   if ( $userdata['session_logged_in'] )
   {
      $sql = "SELECT t.forum_id, t.topic_id, p.post_time
         FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
         WHERE p.post_id = t.topic_last_post_id
            AND p.post_time > " . $userdata['user_lastvisit'] . "
            AND t.topic_moved_id = 0";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
      }

      $new_topic_data = array();
      while( $topic_data = $db->sql_fetchrow($result) )
      {
         $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
      }
      $db->sql_freeresult($result);
   }

   //
   // Obtain list of moderators of each forum
   // First users, then groups ... broken into two queries
   //
   $sql = "SELECT aa.forum_id, u.user_id, u.username
      FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
      WHERE aa.auth_mod = " . TRUE . "
         AND g.group_single_user = 1
         AND ug.group_id = aa.group_id
         AND g.group_id = aa.group_id
         AND u.user_id = ug.user_id
      GROUP BY u.user_id, u.username, aa.forum_id
      ORDER BY aa.forum_id, u.user_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
   }

   $forum_moderators = array();
   while( $row = $db->sql_fetchrow($result) )
   {
      $forum_moderators[$row['forum_id']][] = color_group_colorize_name($row['user_id']);
   }
   $db->sql_freeresult($result);

   $sql = "SELECT aa.forum_id, g.group_id, g.group_name
      FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
      WHERE aa.auth_mod = " . TRUE . "
         AND g.group_single_user = 0
         AND g.group_type <> " . GROUP_HIDDEN . "
         AND ug.group_id = aa.group_id
         AND g.group_id = aa.group_id
      GROUP BY g.group_id, g.group_name, aa.forum_id
      ORDER BY aa.forum_id, g.group_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
   }

   while( $row = $db->sql_fetchrow($result) )
   {
      $forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
   }
   $db->sql_freeresult($result);

   //
   // Find which forums are visible for this user
   //
   $is_auth_ary = array();
   $is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata, $forum_data);
    if (!isset($board_config['topic_title_index_size'])){
       $board_config['topic_title_index_size'] = 20;  //Set this to size limit
    }

   //
   // Start output of page
   //
   define('SHOW_ONLINE', true);
   $page_title = $lang['Index'];
   include($phpbb_root_path . 'includes/page_header.'.$phpEx);

   $template->set_filenames(array(
      'body' => 'index_body.tpl')
   );
$sql = "SELECT link_id, link_name, link_img, link_queue FROM " . LINKS_TABLE . " ORDER BY link_queue, link_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, "Could not obtain links information.", '', __LINE__, __FILE__, $sql);
   }

   $links_row = array();
   while ( $row = $db->sql_fetchrow($result) )
   {
      $links_row[] = $row;
   }

   if( count($links_row) > 0 )
   {
      for($m = 0; $m < count($links_row); $m++)
      {
         $template->assign_block_vars('linkrow', array(
            'LINK_LOGO' => $links_row[$m]['link_img'],
            'LINK_NAME' => $links_row[$m]['link_name'],
            'U_LINK'  => append_sid('link.'.$phpEx.'?id='.$links_row[$m]['link_id'])
         ));
      }
   }

   $template->assign_vars(array(
'TOTAL_TOPICS' => sprintf($l_total_topic_s, $total_topics),
      'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
      'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
      'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),

      'FORUM_IMG' => $images['forum'],
      'FORUM_NEW_IMG' => $images['forum_new'],
      'FORUM_LOCKED_IMG' => $images['forum_locked'],

      'L_FORUM' => $lang['Forum'],
      'L_TOPICS' => $lang['Topics'],
      'L_REPLIES' => $lang['Replies'],
      'L_VIEWS' => $lang['Views'],
      'L_POSTS' => $lang['Posts'],
      'L_LASTPOST' => $lang['Last_Post'],
      'L_NO_NEW_POSTS' => $lang['No_new_posts'],
      'L_NEW_POSTS' => $lang['New_posts'],
      'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
      'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
      'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
'L_LINKS_TITLE' => $lang['links_title'],

      'L_MODERATOR' => $lang['Moderators'],
      'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
      'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],

      'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
   );

   //
   // Okay, let's build the index
   //
   for($i = 0; $i < $total_categories; $i++)
   {
      $cat_id = $category_rows[$i]['cat_id'];

      //
      // Should we display this category/forum set?
      //
      $display_forums = false;
      for($j = 0; $j < $total_forums; $j++)
      {
         if ( $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'] && $forum_data[$j]['cat_id'] == $cat_id )
         {
            $display_forums = true;
         }
      }

      //
      // Yes, we should, so first dump out the category
      // title, then, if appropriate the forum list
      //
      if ( $display_forums )
      {
         $template->assign_block_vars('catrow', array(
            'CAT_ID' => $cat_id,
            'CAT_DESC' => $category_rows[$i]['cat_title'],
            'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
         );

         if ( $viewcat == $cat_id || $viewcat == -1 )
         {
            for($j = 0; $j < $total_forums; $j++)
            {
               if ( $forum_data[$j]['cat_id'] == $cat_id )
               {
                  $forum_id = $forum_data[$j]['forum_id'];$forum_icon = 'images/forum_icon/' . $forum_id . '.gif';

                  if ( $is_auth_ary[$forum_id]['auth_view'] && $forum_data[$j]['forum_sub'] ==0)
                  {
                     if ( $forum_data[$j]['forum_status'] == FORUM_LOCKED )
                     {
                        $folder_image = $images['forum_locked'];
                        $folder_alt = $lang['Forum_locked'];
                     }
                     else
                     {
                        $unread_topics = false;
                        if ( $userdata['session_logged_in'] )
                        {
                           if ( !empty($new_topic_data[$forum_id]) )
                           {
                              $forum_last_post_time = 0;

                              while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
                              {
                                 if ( empty($tracking_topics[$check_topic_id]) )
                                 {
                                    $unread_topics = true;
                                    $forum_last_post_time = max($check_post_time, $forum_last_post_time);

                                 }
                                 else
                                 {
                                    if ( $tracking_topics[$check_topic_id] < $check_post_time )
                                    {
                                       $unread_topics = true;
                                       $forum_last_post_time = max($check_post_time, $forum_last_post_time);
                                    }
                                 }
                              }

                              if ( !empty($tracking_forums[$forum_id]) )
                              {
                                 if ( $tracking_forums[$forum_id] > $forum_last_post_time )
                                 {
                                    $unread_topics = false;
                                 }
                              }

                              if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
                              {
                                 if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
                                 {
                                    $unread_topics = false;
                                 }
                              }

                           }
                        }

                        $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum'];
                        $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
                     }
//forum_sub start
                     for($k=0;$k<count($forum_sub2[$forum_id]);$k++)
                     {
                        $unread_topics = false;
                        $forum_id2=$forum_sub2[$forum_id][$k];
                        if ( $userdata['session_logged_in'] )
                        {
                           if ( !empty($new_topic_data[$forum_id2]) )
                           {
                              $forum_last_post_time = 0;
                              while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id2]) )
                              {
                                 if ( empty($tracking_topics[$check_topic_id]) )
                                 {
                                    $unread_topics = true;
                                    $forum_last_post_time = max($check_post_time, $forum_last_post_time);
                                 }
                                 else
                                 {
                                    if ( $tracking_topics[$check_topic_id] < $check_post_time )
                                    {
                                       $unread_topics = true;
                                       $forum_last_post_time = max($check_post_time, $forum_last_post_time);
                                    }
                                    if($new_topic_data[$forum_id2][0])
                                    {
                                       $unread_topics = true;
                                    }
                                 }
                              }
                              if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
                              {
                                 if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
                                 {
                                    $unread_topics = false;
                                 }
                              }
                           }
                        }
                        if($is_auth_ary[$forum_id2]['auth_view'])
                        {
                           if($unread_topics)
                           {
                              $forum_sub[$forum_id][$forum_id2] = $forum_sub[$forum_id][$forum_id2].'<img src="images/topnew.gif" alt='.$lang['New_posts'].' border="0">';
                           }
                        }else
                        {
                           unset($forum_sub[$forum_id][$forum_id2]);
                        }
                     }
//forum_sub end

                     $posts = $forum_data[$j]['forum_posts'];
                     $topics = $forum_data[$j]['forum_topics'];

                     if ( $forum_main[$forum_id]['forum_last_post_id'] )
                     {
                        $last_post_time = create_date($board_config['default_dateformat'], $forum_main[$forum_id]['post_time'], $board_config['board_timezone']);

                        $last_post = $last_post_time . '<br />';

                        $last_post .= ( $forum_main[$forum_id]['user_id'] == ANONYMOUS ) ? ( ($forum_main[$forum_id]['post_username'] != '' ) ? $forum_main[$forum_id]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : color_group_colorize_name($forum_main[$forum_id]['user_id']);
                        
                        $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_main[$forum_id]['forum_last_post_id']) . '#' . $forum_main[$forum_id]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                     }
                     else
                     {
                        $last_post = $lang['No_Posts'];
                     }

                     if ( count($forum_moderators[$forum_id]) > 0 )
                     {
                        $l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
                        $moderator_list = implode(', ', $forum_moderators[$forum_id]);
                     }
                     else
                     {
                        $l_moderators = '&nbsp;';
                        $moderator_list = '&nbsp;';
                     }
//forum_sub start
                     if ( count($forum_sub[$forum_id]) > 0 )
                     {
                        $forum_sub_list = implode(', ', $forum_sub[$forum_id]);
                     }
                     else
                     {
                        $forum_sub_list = '';
                     }
                     if(!empty($forum_sub_list))
                     {
                        $forum_sub_list="子版面 : ".$forum_sub_list;
                     }
//forum_sub end

                     $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
                     $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

                     $template->assign_block_vars('catrow.forumrow',   array(
                        'ROW_COLOR' => '#' . $row_color,
                        'ROW_CLASS' => $row_class,
                        'FORUM_FOLDER_IMG' => $folder_image,'FORUM_ICON' => $forum_icon, // 討論區 ICON
                        'FORUM_NAME' => $forum_data[$j]['forum_name'],
                        'FORUM_DESC' => $forum_data[$j]['forum_desc'],
'FORUM_NAME_SUB' => $forum_sub_list,
                        'POSTS' => $forum_main[$forum_id]['forum_posts'],
                        'TOPICS' => $forum_main[$forum_id]['forum_topics'],
                        'LAST_POST' => $last_post,
                        'MODERATORS' => $moderator_list,
'LAST_TOPIC' => $is_auth_ary[$forum_data[$j]['forum_id']]['auth_read'] ? (strlen($forum_data[$j]['topic_title']) > $board_config['topic_title_index_size']) ? substr($forum_data[$j]['topic_title'], 0, ($board_config['topic_title_index_size'] - 2)) . "..." : $forum_data[$j]['topic_title'] : "",
                        'U_LAST_TOPIC' => append_sid("viewtopic.$phpEx?"  . POST_TOPIC_URL . "=" . $forum_data[$j]['topic_id']),

                        'L_MODERATOR' => $l_moderators,
                        'L_FORUM_FOLDER_ALT' => $folder_alt,

                        'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
                     );
                  }
               }
            }
         }
      }
   } // for ... categories

}// if ... total_categories
else
{
   message_die(GENERAL_MESSAGE, $lang['No_forums']);
}

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>


非常感謝




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-04-15 9:32 am

你的

代碼: 選擇全部
                     if ( $forum_main[$forum_id]['forum_last_post_id'] )
                     {
                        $last_post_time = create_date($board_config['default_dateformat'], $forum_main[$forum_id]['post_time'], $board_config['board_timezone']);

                        $last_post = $last_post_time . '<br />';

                        $last_post .= ( $forum_main[$forum_id]['user_id'] == ANONYMOUS ) ? ( ($forum_main[$forum_id]['post_username'] != '' ) ? $forum_main[$forum_id]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : color_group_colorize_name($forum_main[$forum_id]['user_id']);
                         
                        $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_main[$forum_id]['forum_last_post_id']) . '#' . $forum_main[$forum_id]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                     }


裡面沒有$forum_data[$j]['topic_title']
當然顯示不出子版面最新主題



yuanyu
 

文章yuanyu » 2005-04-15 12:01 pm

請問
$forum_data[$j]['topic_title']
這段語法要加在哪呢?

謝謝




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-04-15 7:59 pm

$forum_data[$j]['topic_title'] 是顯示主題的參數
看你想怎麼放,沒有一定的答案
放的位子會影響你的風格
上面的文已經告訴你要放在哪個區域內了,每個人的頁面風格不一樣
剩下的需要你自己去嚐試


水色論壇 http://www.et99.net
簡恩峻分享

訪客
 

文章訪客 » 2005-08-04 10:02 pm

小弟裝了子分區1.1版,動作都無問題
但卻發現子分區文章不會跟主板文章一同計算~
檢查了好幾天
也花了好幾天爬文~
卻仍無所獲~
冒昧請問前輩,小弟該再檢查哪些地方呢?
謝謝~




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-08-05 7:59 am

Anonymous 寫:小弟裝了子分區1.1版,動作都無問題
但卻發現子分區文章不會跟主板文章一同計算~
檢查了好幾天
也花了好幾天爬文~
卻仍無所獲~
冒昧請問前輩,小弟該再檢查哪些地方呢?
謝謝~


只有第一層子版才會一同計算



訪客
 

文章訪客 » 2005-08-05 4:41 pm

感謝ETERNAL前輩的提點
不過小弟是第一層子版就不會一同計算了~

請前輩在提示一些地方讓小弟去找找...
衷心感謝




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-08-05 7:33 pm

Anonymous 寫:感謝ETERNAL前輩的提點
不過小弟是第一層子版就不會一同計算了~

請前輩在提示一些地方讓小弟去找找...
衷心感謝


計算方式是這樣寫,修改說明裡面有
代碼: 選擇全部
      $forum_main[$row['main_sub']]['forum_posts']=$forum_main[$row['main_sub']]['forum_posts']+$row['forum_posts'];
      $forum_main[$row['main_sub']]['forum_topics']=$forum_main[$row['main_sub']]['forum_topics']+$row['forum_topics'];




訪客
 

文章訪客 » 2005-08-05 8:02 pm

小弟也研究了這一段好久...
真的是麻煩您了..

能否請您撥點空幫小弟看一下index.php
感謝
http://home.pchome.com.tw/star/akira_02/index.php
如需其他檔案請告知..小弟最快時間奉上~
萬分感激




ETERNAL
 
文章: 2937
註冊時間: 2003-12-03 11:08 pm
性別: 男生

文章ETERNAL » 2005-08-05 9:38 pm

沒辦法看
你要檢查$row['forum_topics']裡面是否有數據,是否有加入$forum_main[$row['main_sub']]['forum_topics']

以及是否有對應到風格參數裡面
'POSTS' => $forum_main[$forum_id]['forum_posts'],
'TOPICS' => $forum_main[$forum_id]['forum_topics'],


水色論壇 http://www.et99.net
簡恩峻分享

下一頁

回到 架站討論

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 11 位訪客