大家好!
這個教學將展示給您如何在 phpBB3 中增加新的頁面. 為什麼您需要如此做呢? 比方說, 您想要新增一個類似您的論壇的網頁. 這新的頁面能夠包含任何您想要的東西, 從透過簡單的文字像是規則的列表, 到更複雜的事情像是其他的 PHP scripts, 例如: 行事曆. 讓我們開始吧!
這 aboutus.php 檔案
當您建立一個 aboutus.php 頁面, 請確認在 <?php 之前, 以及在 ?> 之後, 沒有留下空行.
例如, 我們要建立一個簡單的頁面來說明關於網站的一些事情, 請複製以及貼上下列的代碼到您最愛的文字編輯器中:
代碼: 選擇全部
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
page_header('Title Here');
$template->set_filenames(array(
'body' => 'yourpage_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
是嗎? 不全都是, 讓我解釋一下.
如果您正在建立一個完整地自訂頁面, 那麼您可能不需要如此做; 但是如果您需要使用到 phpBB 語言檔, 那麼請改變這一行:
代碼: 選擇全部
$user->setup();
代碼: 選擇全部
$user->setup('base-name-of-language-file-here');
代碼: 選擇全部
$user->setup('viewtopic');
代碼: 選擇全部
page_header('Title Here');
接著, 您需要改變這一行:
代碼: 選擇全部
'body' => 'yourpage_body.html',
獎勵 (限制訪客瀏覽) 的秘訣
如果您想要只有已經登入的會員 (限制訪客) 瀏覽此頁的話, 那麼可以這麼做, 找到這行:
代碼: 選擇全部
$user->setup();
代碼: 選擇全部
if ($user->data['user_id'] == ANONYMOUS)
{
login_box('', $user->lang['LOGIN']);
}
下一步, 我們將建立包含 aboutus.php 實際內容的 HTML 檔案. 再一次, 使用您最愛的文字編輯器開啟此檔, 複製以下代碼:
代碼: 選擇全部
<!-- INCLUDE overall_header.html -->
<h2>Title Here</h2>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="content">
<p>
Content in here.
</p>
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->
這是相當容易的. 要改變這一頁顯示在上頭的大字, 只要改變這一行:
代碼: 選擇全部
<h2>Title Here</h2>
而這個區塊將取代成您的實際內容:
代碼: 選擇全部
Content in here.
代碼: 選擇全部
We were founded this year to bring you the best forum on the Internet!
We promise to do the following:
<ul>
<li>Provide new content</li>
<li>provide a friendly atmosphere</li>
<li>Provide an environment where you can have fun!</li>
</ul>
如果您依照這裡的說明, 那麼這兩個檔案現在看起來應該像這樣:
aboutus.php:
代碼: 選擇全部
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
page_header('About Us');
$template->set_filenames(array(
'body' => 'aboutus_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
代碼: 選擇全部
<!-- INCLUDE overall_header.html -->
<h2>About Us</h2>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="content">
<p>
We were founded this year to bring you the best forum on the Internet!
We promise to do the following:
<ul>
<li>Provide new content</li>
<li>provide a friendly atmosphere</li>
<li>Provide an environment where you can have fun!</li>
</ul>
</p>
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->
最後的步驟
現在儲存已經修改的檔案, 上傳到您的網站. 其中, aboutus_body.html 是上傳到 styles/your_style/template/ 底下; aboutus.php 則是上傳到 phpBB 的根目錄底下 (這個地方有存放檔案, 像是 faq.php, viewforum.php, viewtopic.php,...等.).
最後, 在瀏覽器網址列輸入 http://YOUR_WERSITE/phpBB3_ROOT/aboutus.php 去檢視您的新網頁!
與您分享之!
--
資料來源:
http://www.phpbb.com/kb/article/add-a-n ... -to-phpbb/