如何新增頁籤 (tab)
新版的 SMF 加上了新的佈景,現在預設的佈景跟之前的很不相同。
選單也都改成了頁籤的方式,代替了之前使用的圖示按鈕。
如果你要新增頁籤,譬如說加上 "相簿" 的連結,可以照下面的方式。
第一步:
打開 index.template.php
尋找:
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
改成:
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'gallery')))
你可以看到最後面加上了 gallery。
第二步:
相同檔案 index.template.php
尋找:
// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt[103] , '</a>
</td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
將上面的代碼複製,然後貼到你要顯示的地方,例如在上面的代碼後面。
然後將裡面的 home 改成 gallery,如同下面 (共有三個):
// Show the [gallery] button.
echo ($current_action=='gallery' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'gallery' ? 'active_back' : 'back' , '">
<a href="http://website.com/gallery">相簿</a>
</td>' , $current_action == 'gallery' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
$current_action=='gallery' 裡的 gallery 必須跟第一步裡改的一樣。
接下來要改連結的位置,將上面的
http://website.com/gallery 改成你相簿的網址。
你也可以把 "相簿" 放在中文檔裡。
打開 index.chinese-traditional-utf8.php 或 index.chinese-traditional-big5.php。
然後到最下面把 $txt[my_gallery] 放在 ?> 之前。
例如:
$txt[my_gallery] = '相簿';
?>
如果是用這個方法,記得連結的那行要改:
<a href="http://website.com/gallery">', $txt[my_gallery], '</a>
如果遇到問題請回覆。
來源:http://www.simplemachines.org/community/index.php?topic=63203.0