ข่าวประชาสัมพันธ์

มาร่วมเป็นกำลังใจให้เว็บด้วยการสมัครสมาชิกวีไอพี ~~ เลือกปีที่ท่านต้องการได้โดยไม่ต้องเรียงปี ~~ ปีละ 350 บาท สมัคร 2 ปีลดเหลือ 600 บาท ~~ มีไลน์กลุ่ม VIP จำนวนหลายร้อยท่าน เอาไว้ปรึกษางานซ่อม ~~ เข้าถึงข้อมูลด้านเทคนิค ข้อมูลเชิงลึกมากมาย.....


ผู้เขียน หัวข้อ: วิธีสร้าง MOD เว็บบอร์ด SMF ใช้งานเองแบบง่ายๆ  (อ่าน 4158 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ Auto Man

  • Administrator
  • หัวหน้าศูนย์ซ่อมสร้าง
  • *****
  • เจ้าของกระทู้
  • Joined: ก.ย. 2558
  • กระทู้: 37385
  • สมาชิกลำดับที่ : 1
  • เพศ: ชาย
  • มือผู้ให้ย่อมสูงกว่ามือผู้รับ
    • เว็บชุมชนคนรักช่างยนต์
    • อีเมล์
หลายคนสงสัยว่าทำไมต้องสร้าง mod ใช้เองให้มันยุ่งยาก ในเมื่อของฝรั่งก็มีให้เลือกใช้เยอะแยะไป อันนี้ผมว่ามันก็จริงนะครับ แต่คุณรู้ไหมครับว่า mod เกือบทุกตัวมีแต่คนต่างชาติเขาเป็นคนทำ "แล้วทำไมคนไทยจะทำให้คนอื่นใช้บ้างไม่ได้" ผมว่าความรู้ความสามารถของไทยเราก็ไม่ด้อยไปกว่าชาติใดในโลกเลยนะครับ

"แค่เราลงมือสร้าง"
เริ่มต้นด้วยการศึกษาว่าเขาทำกันยังไงที่ลิงค์นี้ครับ http://www.simplemachines.org/...munity/index.php?topic=20319.0

หลังจากที่เข้าไปศึกษาวิธีสร้างตามลิงค์ข้างบนแล้ว ให้เราดาวน์โหลดไฟล์ "package-sdk_0.6.zip" ซึ่งอยู่ในไฟล์แนบของลิงค์ข้างบนแล้วแตกไฟล์ออกจะเห็นไฟล์สำหรับใช้ทำเป็น mod ติดตั้งของเว็บบอร์ด smf

หลังจากที่เราได้ไฟล์ติดตั้งมาแล้วทีนี่ก็มาถึงวิธีการสร้าง mod เพื่อใช้งานกันครับ
ขั้นตอนแรกเราจะเริ่มสร้าง mod ตัวง่ายๆกันก่อนนะครับ โดยผมจะเลือกสร้าง mod "ย้ายเวอร์ชั่นเว็บบอร์ด SMF ให้ชิดขวา"

ขั้นตอนแรกให้เรานำไฟล์ต่อไปนี้มาแก้ไข
1. package-info.xml 
2. modification.xml

วิธีแก้ไขไฟล์ package-info.xml
ภายในไฟล์จะประกอบไปด้วยโค๊ดเหล่านี้
โค๊ด: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info ">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 This is a simplified package manifest for SMF packages.

 ATTENTION: If you are trying to install this manually, you should try
 the package manager.  If it will not work for you, please take a look
 at the following for information on this format:
  http://www.simplemachines.org/redirect/manual_mod_install

================================================================================

 This script can be used to make your package do many different things.
 The following documentation should be available on the format of this
 file and the things you can do with it:
  http://www.simplemachines.org/redirect/mod_package_sdk

 Please see the other included file, package-info_advanced.xml, for
 a more detailed description of what you can do with this file.

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<package-info xmlns="http://www.simplemachines.org/xml/package-info " xmlns:smf="http://www.simplemachines.org/ ">
 <!-- For the id, always use something unique - put your name, a colon, and then the package name. -->
 <id>username:testing123</id>
 <!-- Below should be the name of this package. -->
 <name>Testing, 1-2-3!</name>
 <!-- The version of this modification.  Keep it numeric so PHP can tell that old < new. -->
 <version>1.0</version>

 <!-- Type, one of: modification, avatar, language. -->
 <type>modification</type>

 <!-- Installation, the key part of this file. -->
 <install>
  <readme>readme.txt</readme>
  <modification>install.xml</modification>
  <code>add_settings.php</code>
 </install>

 <!-- Don't forget something to make it uninstallable! -->
 <uninstall>
  <modification reverse="true">install.xml</modification>
 </uninstall>
</package-info>
สวัสดีคุณ...ผู้เยี่ยมชม  กด ❤ ถูกใจโพสท์นี้ หรือยัง...
ต้องการสมัครสมาชิก VIP สมัครได้ที่นี่...   หรือทาง Line ID: k.sonchai

ออฟไลน์ Auto Man

  • Administrator
  • หัวหน้าศูนย์ซ่อมสร้าง
  • *****
  • เจ้าของกระทู้
  • Joined: ก.ย. 2558
  • กระทู้: 37385
  • สมาชิกลำดับที่ : 1
  • เพศ: ชาย
  • มือผู้ให้ย่อมสูงกว่ามือผู้รับ
    • เว็บชุมชนคนรักช่างยนต์
    • อีเมล์
วิธีสร้าง MOD เว็บบอร์ด SMF ใช้งานเองแบบง่ายๆ
« ตอบกลับ #1 เมื่อ: 26 ธันวาคม 2558, 05:22:28 »
  • ขึ้นบน
  • ลงล่าง
  • จากข้างบนให้เราแก้ไขโค๊ดดังต่อไปนี้

    1.<id>username:testing123</id>  แก้เป็น <id>ชื่อของเรา:ชื่อของmodที่เราสร้าง</id> (ชื่อของmodห้ามเว้นวรรคโดยเด็ดขาด)

    2.<name>Testing, 1-2-3!</name> แก้เป็น <name>ชื่อของmodที่เราสร้าง</name> (ชื่อตรงนี้สามารถเว้นวรรคได้)

    3.<version>1.0</version>  แก้เป็น <version>เวอร์ชั่นmodของเรา</version> (ตั้งค่าเวอร์ชั่นmodตามต้องการ)

    4.<install>  แก้เป็น <install for="2.0.7"> (ใส่เวอร์ชั่นของเว็บบอร์ดที่รองรับmodนี้)
    4.1 จากนั้นให้เราลบโค๊ดนี้ทิ้ง <code>add_settings.php</code>

    5.<uninstall> แก้เป็น <uninstall for="2.0.7"> (ใส่เวอร์ชั่นของเว็บบอร์ดที่รองรับmodนี้)

    หลังจากแก้ไขเสร็จแล้วจะมีโค๊ดอยู่2บรรทัดที่ยังไม่ได้แก้ไขคือโค๊ดต่อไปนี้

    1.<readme>readme.txt</readme> คือไฟล์ readme.txt ที่เราต้องสร้างขึ้นมาใหม่เพื่อใส่ข้อมูลต่างๆเช่น อธิบายคุณสมบัติของmod วิธีใช้งานmod และที่สำคัญต้องแสดงลิขสิทธิ์ของmodด้วย

    2. <modification>install.xml</modification> คือไฟล์ติดตั้ง install.xml  ที่เราจะต้องเขียนคำสั่งให้มันแก้ไขโค๊ดของเราในขั้นตอนต่อไป


    วิธีแก้ไขไฟล์ modification.xml

    โค๊ด: [Select]
    <?xml version="1.0"?>
    <!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification ">
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     This is an example modification file for SMF packages.

     ATTENTION: If you are trying to install this manually, you should try
     the package manager.  If it will not work for you, please take a look
     at the following for information on this format:
      http://www.simplemachines.org/redirect/manual_mod_install

    ================================================================================

     Modification files can be used to modify files so that they do what
     your package needs them to do to work properly.

     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <modification xmlns="http://www.simplemachines.org/xml/modification " xmlns:smf="http://www.simplemachines.org/ ">
     <!-- This information needs to be the same as that in the package-info.xml. -->
     <id>username:testing123</id>
     <version>1.0</version>

     <!-- Edit a specific file.. -->
     <file name="$sourcedir/Filename.php">
      <!-- A seach operation, with search rules and code to modify the file with. -->
      <operation>
       <!-- Search for this text before the code we add.  You can also search for after, and the end of the file. -->
       <search position="before"><![CDATA[
    Search for some code to add stuff after.
    ]]></search>
       <!-- Add this text when we find it.  Note that it's on it's own line on purpose, and the CDATA keeps things clean. -->
       <add><![CDATA[
    This is what to add.
    ]]></add>
      </operation>

      <operation>
       <search position="replace"><![CDATA[
    Another search operation?
    ]]></search>
       <add><![CDATA[
    Yes, another.  This time, replacing!
    ]]></add>
      </operation>
     </file>
    </modification>

    จากไฟล์ข้างบนให้เราแก้ไขโค๊ดดังต่อไปนี้

    1.<id>username:testing123</id> แก้เป็น <id>ชื่อของเรา:ชื่อของmodที่เราสร้าง</id> (ชื่อของmodห้ามเว้นวรรคโดยเด็ดขาด)

    2.<version>1.0</version> แก้เป็น <version>เวอร์ชั่นmodของเรา</version> (ตั้งค่าเวอร์ชั่นmodตามต้องการ)

    3.<file name="$sourcedir/Filename.php"> แก้เป็น <file name="$themedir/css/index.css"> (โค๊ดตัวนี้คือประตูทางเข้าไปจัดไฟล์ของmodเรา)

    4.<operation>
       <!-- Search for this text before the code we add.  You can also search for after, and the end of the file. -->
       <search position="before"><![CDATA[
    Search for some code to add stuff after.
    ]]></search>

    แก้เป็น
    <!-- Search for this text before the code we add.  You can also search for after, and the end of the file. -->
       <search position="replace"><![CDATA[
    #footer_section
    {
     text-align: center;
     background: url(../images/theme/main_block.png) no-repeat 0 -820px;
     padding-left: 20px;
    }
    ]]></search>

    จากข้างบนให้สังเกตุตรงจุดนี้นะครับ <search position="before"><![CDATA[
    Search for some code to add stuff after.
    ]]></search>

    จุดที่ผมแก้ไขคือ
    1. <search position="before">   ผมแก้ before เป็น replace

    2.<![CDATA[Search for some code to add stuff after.]]></search> ผมเปลี่ยนข้อความ "Search for some code to add stuff after." เป็นโค๊ด

    5.<!-- Add this text when we find it.  Note that it's on it's own line on purpose, and the CDATA keeps things clean. -->
       <add><![CDATA[
    This is what to add.
    ]]></add>
      </operation>

    แก้เป็น
     <!-- Add this text when we find it.  Note that it's on it's own line on purpose, and the CDATA keeps things clean. -->
       <add><![CDATA[
    #footer_section
    {
     text-align: right;
     background: url(../images/theme/main_block.png) no-repeat 0 -820px;
     padding-left: 20px;
    }
    ]]></add>
      </operation>

    จุดที่ผมแก้ไขคือ
    1.<![CDATA[This is what to add.]]></search> ผมเปลี่ยนข้อความ "This is what to add." เป็นโค๊ด

    หลังจากเสร็จแล้วให้เราลบโค๊ดส่วนที่ไม่ใช้ทิ้งคือโค๊ดนี้

    โค๊ด: [Select]
    <operation>
       <search position="replace"><![CDATA[
    Another search operation?
    ]]></search>
       <add><![CDATA[
    Yes, another.  This time, replacing!
    ]]></add>
      </operation>

    เสร็จแล้วให้บันทึกและเปลี่ยนชื่อไฟล์เป็น install.xml

    จาก mod ที่เราสร้างก็จะมีไฟล์ทั้งหมด 3 ไฟล์หลักๆคือ
    1. install.xml
    2.readme.txt
    3.package-info.xml

    ขั้นตอนสุดท้ายให้รวมไฟล์ทั้ง3เป็นไฟล์ .zip เพียงเท่านี้เราก็จะได้ "mod เว็บบอร์ด smf" สร้างโดยผีมือของตัวท่านเองเป็นที่เรียบร้อยไม่ยากเลยใช่ไหมครับ.
    สวัสดีคุณ...ผู้เยี่ยมชม  กด ❤ ถูกใจโพสท์นี้ หรือยัง...
    ต้องการสมัครสมาชิก VIP สมัครได้ที่นี่...   หรือทาง Line ID: k.sonchai

    ออฟไลน์ Auto Man

    • Administrator
    • หัวหน้าศูนย์ซ่อมสร้าง
    • *****
    • เจ้าของกระทู้
    • Joined: ก.ย. 2558
    • กระทู้: 37385
    • สมาชิกลำดับที่ : 1
    • เพศ: ชาย
    • มือผู้ให้ย่อมสูงกว่ามือผู้รับ
      • เว็บชุมชนคนรักช่างยนต์
      • อีเมล์
    วิธีสร้าง MOD เว็บบอร์ด SMF ใช้งานเองแบบง่ายๆ
    « ตอบกลับ #2 เมื่อ: 26 ธันวาคม 2558, 05:23:42 »
  • ขึ้นบน
  • ลงล่าง
  • ขอบคุณข้อมูลดีๆ มาจากที่นี่
    สวัสดีคุณ...ผู้เยี่ยมชม  กด ❤ ถูกใจโพสท์นี้ หรือยัง...
    ต้องการสมัครสมาชิก VIP สมัครได้ที่นี่...   หรือทาง Line ID: k.sonchai

    วิธีสร้าง MOD เว็บบอร์ด SMF ใช้งานเองแบบง่ายๆ
    « ตอบกลับ #2 เมื่อ: 26 ธันวาคม 2558, 05:23:42 »