- ชื่อ: Slide Menu
- ผู้เขียน: UnclEo
- นำเสนอโดย: DexMoreGroup
- ประเภท: Theme Enhancements
- รองรับ: SMF 1.1.xx
- ปรับปรุงล่าสุด: 23 มิถุนายน 2553
รายละเอียด หลาย ๆ ท่านอาจจะเบื่อ menu แบบเดิม ๆ พอดีไปเห็น Themes extreme61 เป็น menu น่าสนใจดีก็เลยแงะมาฝาก SFM corner กัน เอาธีมมาตรฐานนะครับ ธีมอื่น ๆ ก็ใช้ได้เหมือนกัน แต่โค๊ดที่หาอาจไม่เหมือนกัน ท่านที่ใช้ธีมอื่น แล้วหาโค๊ดไม่เจอ ก็เอาไฟล์นี้มาดูกันนะครับ ถ้าโพสในกระทู้ขอให้โพสเป็นโค๊ด นะครับ
ตัวอย่าง

เริ่มต้นกันที่ไฟล์ index.template.php (ไฟล์เดียวแหละ)

ค้นหา -->>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?fin11"></script>
เพิ่มไว้หลัง -->>
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/mootools.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/imagemenu.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/imagemenu2.js"></script>
ค้นหา -->>
// Show the menu here, according to the menu sub template.
template_menu();
แก้เป็น -->>
<div id="toolbar">',template_menu(),'</div>
ค้นหา -->>
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;
// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}
// Show the start of the tab section.
echo '
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 10px;">
<tr>
<td class="maintab_' , $first , '"> </td>';
// 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>' : '';
// Show the [help] button.
echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'help' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=help">' , $txt[119] , '</a>
</td>' , $current_action == 'help' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// How about the [search] button?
if ($context['allow_search'])
echo ($current_action == 'search' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'search' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=search">' , $txt[182] , '</a>
</td>' , $current_action == 'search' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'admin' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>
</td>' , $current_action == 'admin' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'profile' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>
</td>' , $current_action == 'profile' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>
</td>' , $current_action == 'pm' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'calendar' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a>
</td>' , $current_action == 'calendar' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
</td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// The end of tab section.
echo '
<td class="maintab_' , $last , '"> </td>
</tr>
</table>';
}
แก้เป็น -->>
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Comfile style.css
หา -->>
/* The AJAX notifier */
#ajax_in_progress {
background: #002962;
color: white;
text-align: center;
font-weight: bold;
font-size: 18pt;
padding: 3px;
width: 100%;
position: fixed;
top: 0;
left: 0;
}
เพิ่มไว้หลัง -->>
#toolbar {
height: 70px;
background: #000000 url(images/mootools_03.png) repeat-x;
margin-left: 9px;
margin-right: 9px;
}
เพิ่มไว้หลัง -->>
#kwick {
width : 100%;
}
#kwick .kwicks {
background : transparent;
display : block;
height : 70px;
margin : 0;
padding : 0;
}
#kwick li {
float : left;
margin : 0;
padding : 0;
list-style : none;
}
#kwick .kwick {
display : block;
cursor : pointer;
overflow : hidden;
height : 70px;
width : 78px;
}
#kwick .kwick span {
display : none;
}
#kwick .opt0 {
background-color : transparent;
outline : none;
}
#kwick .opt1 {
background-color:transparent;
outline: none
}
#kwick .opt2 {
background-color:transparent;
outline: none
}
#kwick .opt3 {
background-color:transparent;
outline: none
}
#kwick .opt4 {
background-color:transparent;
outline: none
}
#kwick .opt5 {
background-color:transparent;
outline: none
}
#kwick .opt6 {
background-color:transparent;
outline: none;
}
#kwick .opt7 {
background-color:transparent;
outline: none
}
#kwick .opt8 {
background-color:transparent;
outline: none
}
#kwick .opt9 {
background-color:transparent;
outline: none
}
#kwick .opt10 {
background-color:transparent;
outline: none
}
#kwick .opt11 {
background-color:transparent;
outline: none
border-right: 0px none;
}
ดาวน์โหลดรูปครับ

แตกไฟล์แล้วอัฟโหลดรูปทั้งหมดไปไว้ใน $Themesdir/default/images/thai-utf8
ดาวน์โหลดอีกไฟล์ครับ
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Comไฟล์นี้เป็นไฟล์ *.psd ครับเอาไว้ให้ท่านแก้ไขกราฟิก เปลี่ยนรูแบบสีสรรของ menu ตามใจชอบ
ดาวน์โหลดอีกทีครับ
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Comอันนี้เป็น javaScript + mootools ครับทั้งหมด 3 ไฟล์ แตกไฟล์แล้วเอาไปไว้ใน $Themesdir ใช้ธีมใหนไว้ธีมนั้นนะครับ
##อธิบายโค๊ดแต่ละส่วนคร่าว ๆ นะครับ
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/mootools.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/imagemenu.js"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/imagemenu2.js"></script>
นี่คือการเรียกไฟล์ทั้ง 3 ไฟล์มาใช้งานครับ ให้สังเกตุที่ .js นั่นคือ javaScript ทั้ง 3 ไฟล์
ส่วนที่ 2
<div id="kwick">
คือการเรียกใช้งาน #kwick จาก style.css ที่เราเพิ่มไว้ครับ
ส่วนที่ 3
<div id="toolbar">',template_menu(),'</div>
เป็นการเรียกใน #toolbar ที่เราเพิ่มใน style.css เหมือนกัน menu จะอยู่ใน id นี้ เราสามารถเปลียนขนาด พื้นหลังได้ตามใจชอบ
แต่ต้องสอดคล้องกับ #kwick
ส่วนที่ 4
// Show the [home] button.
echo '<li><a href="', $scripturl, '" class="kwick opt1">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/home.png" alt="' . $txt[103] . '" style="margin: 0px 0;" border="0" /><span>' : $txt[103]), '</span></a></li>';
นี่คือส่วนของปุ่ม [button]ที่เราสามารถเพิ่มหรือ ลดได้ตามความต้องการ เราจะให้ลิงค์ไปทีใหนก็เปลี่ยนที่
a href="', $scripturl, อันนี้คือลิงค์หน้าแรกของบอร์ด ส่วนรูปเราก็เปลี่ยนได้ตามความต้องการโดยเปลี่ยนที่
home.png ยกให้เป็นตัวอย่างนะครับ ที่สำคัญจำนวน
kwick opt1 ใน รายการปุ่ม
นี้จะต้องเท่ากันกับใน style.css นะครับ มันจะมีตั้งแต่ kwick opt1 - kwick opt11 ถ้าในรายการเมนูนี้มีถึง 12 เราก็ต้องเพิ่ม kwick opt12 ใน style.css ด้วย ใน style.css จะมีน้อยกว่าในรายการ menu ไม่ได้ แต่มีมากกว่าได้
ลิงค์หัวข้อ:
http://dexmore.com/topic/332