:: JustUsers.net ::
:: คนทำเว็บ :: => Simple Machines Forum [SMF] => Configuration => ข้อความที่เริ่มโดย: UnclEo ที่ 02, สิงหาคม 2010, 03:19:10 PM
-
- ชื่อ: Google Search for SMF
- ผู้เขียน: UnclEo (http://dexmore.com/user/2)
- นำเสนอโดย: DexMoreGroup (http://dexmore.com)
- ประเภท: Search Engine Optimization
- รองรับ: SMF 1.1.xx, 2.0.xx
- ปรับปรุงล่าสุด: 2 สิงหาคม 2553
รายละเอียด
ให้ SMF ใช้ฟอร์มการค้นหาโดย google เป็นการผูกมิตรกับ google เป็นวิธีหนึ่งในหลายๆ วิธีของการทำเสียว และยังสามารถค้นหาภายในบอร์ดได้เหมือนเดิมด้วยการค้นหาชั้นสูง
ตัวอย่าง
(http://img715.imageshack.us/img715/5322/googlesearch.jpg)
สำหรับ SMF 1.1.xx
แก้ไขไฟล์:
file $themesdir/index.tempate.php
ค้นหา -->>
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '
</form>
แก้เป็น -->>
<form action="http://www.google.co.th/cse" id="cse-search-box" target="_blank">
<img alt="dexmore.com" src="' .$settings['images_url']. '/google.gif" width="61" height="24" align="middle" />
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" alt="' , $txt['advanced_search'] , '" title=" ' , $txt['advanced_search'] , ' " /></a>
<input type="hidden" name="cx" value="partner-pub-9273694033855981:t1oxa0xl47u" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="ค้นหา" />
</form>
<script type="text/javascript" src="http://www.google.co.th/cse/brand?form=cse-search-box&lang=th"></script>
file $languagesdir/index.thai-utf8.php
เพิ่ม -->>
$txt['advanced_search'] = 'การค้นหาชั้นสูง';
รูป google.gif (http://img821.imageshack.us/img821/3677/googleb.gif)
อัพโหลดไปไว้ใน $imagesdir
-
สำหรับ SMF 2.0.xx
แก้ไขไฟล์:
file $themesdir/index.template.php
ค้นหา -->>
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '</form>';
แก้เป็น -->>
<form action="http://www.google.co.th/cse" id="cse-search-box" target="_blank">
<img alt="dexmore.com" src="' .$settings['images_url']. '/google.gif" width="61" height="24" align="middle" />
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" alt="' , $txt['advanced_search'] , '" title=" ' , $txt['advanced_search'] , ' " /></a>
<input type="hidden" name="cx" value="partner-pub-9273694033855981:t1oxa0xl47u" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="ค้นหา" />
</form>
<script type="text/javascript" src="http://www.google.co.th/cse/brand?form=cse-search-box&lang=th"></script>';
file $languagesdir/index.thai-utf8.php
เพิ่ม -->>
$txt['advanced_search'] = 'การค้นหาชั้นสูง';
รูป google.gif (http://img821.imageshack.us/img821/3677/googleb.gif)
อัพโหลดไปไว้ใน $imagesdir
-
ขอบคุณครับ ระบบ ค้นหาของ Google ใน SMF หามานานแล้ว เจอซะที ดีกว่า ระบบค้นหาของ SMF หลายเท่าเลย :grin:
-
จะทำยังไงให้บรรทัดต่อจากกล่องค้นหา หายไปครับ หลังจากทำตามที่บอกมา ได้แล้วแต่มันมีบรรทัดเพิ่มมาครับ ทำให้ดูกล่องมันลอยอยู่ 1 บรรทัดครับ
(http://image.free.in.th/z/it/hp111.png) (http://image.free.in.th/show.php?id=aa712ce74019324ea64cb538be13cd04)
Thanks: ฝากรูป (http://www.uppicweb.com)
-
ขอดูโค๊ดที่แก้ไข ก็อบเผื่อด้วย ก่อนหน้า และหลังจากสัก 10 บรรทัด
-
นี่ครับผม
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top" >
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;"target="_blank">
<a href="', $scripturl, '?action=search;advanced" ><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="' , $txt['advanced_search'] , '" title=" ' , $txt['advanced_search'] , ' " /></a>
<input type="text" name="search" value="" style="width: 190px;" />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '
</form>
<form action="http://www.google.co.th/cse" id="cse-search-box" target="_blank">
<img alt="dexmore.com" src="' .$settings['images_url']. '/google.gif" width="61" height="24" align="middle" />
<input type="hidden" name="cx" value="partner-pub-9273694033855981:t1oxa0xl47u" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="ค้นหา" />
</form>
<script type="text/javascript" src="http://www.google.co.th/cse/brand?form=cse-search-box&lang=th"></script>
</td>
</tr>
</table>
</div>';
// Show the menu here, according to the menu sub template.
template_menu();
// Show a random news item!
if (!empty($settings['enable_news'])){
echo ' <br />
<table width="100%" cellpadding="10" cellspacing="1" class="bordercorlor" bgcolor="#666666">
<tr>
<td class="titlebg" align="center"><strong><font size="4">ข่าวประชาสัมพันธ์</font></strong></td>
</tr>
<tr><td bgcolor="#F9F9F9">';
echo $context['random_news_line'];
echo'
</tr></td>
</table>';
}
// The main content should go here.
echo '
<div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';
}
function template_main_below()
{
global $context, $settings, $options, $scripturl, $txt;
echo '
</div>';
-
ก็ไม่เห็นตรงไหนที่แปลกกว่าปกติ ถ้าจะมีก็คง <br /> ที่มีอยู่จุดเดียว
หรืออีกวิธี ลองใช้โค๊ดให้เหมือนต้นฉบับทุกอย่าง
-
ใช้ได้เฉพาะกับธีมมาตรฐานใช่ไหมครับ ผมลองใช้แล้วใช้ได้ดีครับ แต่กับธีม Dilber Multicolor ไม่ได้ครับ ค้นหาโค๊ตนี้ไม่เจอ รบกวนชี้แนะด้วยครับ :huh:
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '</form>';
-
ลองหาเฉพาะ
// Search within current topic?
หาทั้งบรรทัดจะไม่เจอเพราะโค๊ดเขียนไม่เหมือนกัน
-
ผมได้ทำการวางทับแล้วครับ แต่เว็บขึ้น error ครับ ผมต้องแก้ตรงไหนต่อครับ อันนี้ฉบับ Original ขอบคุณล่วงหน้ามากครับ :adore:
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td valign="middle" height="30" class="smalltext" style="padding-left:10px; padding-top:0px; padding-bottom:0px;">
<b>', $txt[102], '</b>: ', $context['random_news_line'], '
</td>
';
echo '
<td valign="middle" height="30" style="padding-top:0px; padding-bottom:0px; padding-right:20px;" class="middletext" align="right">
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0px;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0px;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '
</form>
-
ค้นหา เดิมๆ บรรทัด 252-269
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0px;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0px;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
echo '
</form>
แทนที่ด้วย
<form action="http://www.google.co.th/cse" id="cse-search-box" target="_blank">
<img alt="dexmore.com" src="' .$settings['images_url']. '/google.gif" width="61" height="24" align="middle" />
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" alt="' , $txt['advanced_search'] , '" title=" ' , $txt['advanced_search'] , ' " /></a>
<input type="hidden" name="cx" value="partner-pub-9273694033855981:t1oxa0xl47u" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="ค้นหา" />';
echo '
</form>
<script type="text/javascript" src="http://www.google.co.th/cse/brand?form=cse-search-box&lang=th"></script>
ปล
ถ้าเดี้ยงก็ลองจับเอ็คโค่ย้ายๆ วางๆ
-
ตอนนี้แก้ตามที่บอกแล้วครับ แต่ติดตรงปุ่มค้นหาขึ้นภาษาต่างด้าวครับ รบกวนช่วยแนะนำด้วยครับ ขอบคุณครับ :smiley:
(http://img683.imageshack.us/img683/5646/2892554221814.jpg) (http://imageshack.us/photo/my-images/683/2892554221814.jpg/)
Uploaded with ImageShack.us (http://imageshack.us)
<input type="submit" name="sa" value="&#x0e04;&#x0e49;&#x0e19;&#x0e2b;&#x0e32;" />';
-
value="ค้นหา"
ลองพิมพ์เข้าไปเป็นภาษาไทย หรือไม่ก็ภาษาอังกฤษ
-
ขอบคุณครับ ได้แล้วครับ แต่เป็นภาษาอังกฤษ :yaahoo:
-
ขอขุดหน่อยนะครับ อยากขอบคุณ หานานมากกว่าจะมาเจอ
-
ผมได้สคลิปจาก google มาเป็น
<script>
(function() {
var cx = '861916905788457815:fuvrpb2bgl';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'hxxps://cse.google_com/cse.js?cx=' cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
smf 2.0.14-15 ต้องเอาไปใส่ที่ไหนเพื่อให้ค้นหาโดย google ได้ครับผม
-
ในอินเด็กเทมเพลท ลองวางต่อจากแถวๆนี้
<div id="search">
-
ขอบคุณครับผม :smitten:
สคลิปที่ได้มานั้นหาที่ลง หาข้อมูลวิธีนำไปใช้บน smf ไม่ได้เลย
ไปผ่านตามาว่าถ้าอัพเครื่องมือค้นหาเป็น"(พาร์ทเนอร์ CSE)" จะได้ไอดีเป็น "partner-pub-_______:_______
เมื่อเอามาแทนที่ต้นฉบับของกระทู้นี้ก็สามารถใช้งานได้เลย :dev:
<form action="hปปp://www.google.co.th/cse" id="cse-search-box" target="_blank">
<img alt="dexmore.com" src="' .$settings['images_url']. '/google.gif" width="61" height="24" align="middle" />
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" alt="' , $txt['advanced_search'] , '" title=" ' , $txt['advanced_search'] , ' " /></a>
<input type="hidden" name="cx" value="partner-pub-9273694033855981:t1oxa0xl47u" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="ค้นหา" />
</form>
<script type="text/javascript" src="hปปp://www.google.co.th/cse/brand?form=cse-search-box&lang=th"></script>';