คู่มือการใช้งาน:อินเตอร์วิกิ

From mediawiki.org
This page is a translated version of the page Manual:Interwiki and the translation is 41% complete.
Outdated translations are marked like this.

อินเตอร์วิกิลิงก์ คือลิงก์ไปยังหน้าต่าง ๆ ของโครงการอื่น ๆ โดยใช้รูปแบบลิงก์ภายในเติมเข้าไป

อินเตอร์วิกิลิงก์ ทำให้สามารถเชื่อมโยงไปยังหน้าเว็บ เช่น วิกิพีเดีย, วิกิตำรา, วิกิข่าว เป็นต้น หรือสู่หรือโครงการวิกิของคุณในภาษาต่าง ๆ (ดู คู่มือ:Wiki family )

ลิงก์เช่น [[Wikipedia:Main Page]] จะปรากฏดังนี้: Wikipedia:Main Page และเปลี่ยนทางคุณไปยังหน้าหลักของวิกิพีเดีย

อินเตอร์วิกิลิงก์สู่โครงการอื่น ๆ

Table and query API

อินเตอร์วิกิลิงก์จะเป็นส่วนปฏิคมในตาราง interwiki ของฐานข้อมูลมีเดียวิกิ คุณสามารถดึงรายการอินเตอร์วิกิจากคุณสมบัติ interwikimap ของ siteinfo meta query API หรืออีกนัยหนึ่งโดยการร้องขอ API เช่น api.php?action=query&meta=siteinfo&siprop=interwikimap

ค่าเริ่มต้น

โครงการวิกิมีเดียหลายโครงการ (และอื่น ๆ) พร้อมสำหรับการเชื่อมโยงระหว่างกันโดยปริยาย เพื่อให้คุณสามารถใช้งานได้โดยไม่ต้องแก้ไขฐานข้อมูลของคุณ

ต่อไปนี้คือตัวอย่างของคำนำหน้าอินเตอร์วิกิ ซึ่งพร้อมใช้งานโดยค่าเริ่มต้น (วิกิพีเดียยังมีอยู่, 1.10 และรุ่นหลังจากนั้น):

อักขระเติมหน้า ยูอาร์แอล ปลายทาง ตัวอย่างการใช้งาน
commons https://commons.wikimedia.org/wiki/ [[commons:MediaWiki]]
mediazilla http://bugzilla.wikimedia.org/ [[mediazilla:1209]]
metawikimedia (before version 1.23: metawikipedia) https://meta.wikimedia.org/wiki/ [[metawikimedia:Main Page]]

รายการเต็มรูปแบบของอักขระเติมหน้าอินเตอร์วิกิค่าเริ่มต้นสามารถดูได้ที่ maintenance/interwiki.list

ดู m:Help:Interwiki linking สำหรับสำหรับข้อมูลที่สมบูรณ์เกี่ยวกับการเชื่อมโยงจาก/ถึงโครงการวิกิมีเดีย

ในการติดตั้งบางแห่งไม่มีการติดตั้งไว้ล่วงหน้า ลองใช้ [[metawikipedia:Main Page]] ในกรณีนี้

การเพิ่มเว็บไซต์ใหม่สำหรับการเชื่อมโยงอินเตอร์วิกิ

  • อินเตอร์วิกิลิงก์ได้รับการตั้งค่าในตาราง interwiki ของฐานข้อมูล
  • ในการแก้ไขข้อมูลเหล่านี้ คุณจะต้องแก้ไขฐานข้อมูล ดังต่อไปนี้

ขอแนะนำให้ใช้ ส่วนขยาย "อินเตอร์วิกิ" ซึ่งจะช่วยให้กระบวนการนี้ง่ายขึ้น

เนื่องจากวิกิพีเดียไม่ได้ถูกเซ็ตอัพโดยค่าเริ่มต้นก่อนเวอร์ชั่น 1.10 คุณอาจต้องการเพิ่ม (และโครงการอื่น ๆ ที่คุณต้องการ)

ตัวอย่างด้านล่างแสดงวิธีการตั้งค่า w: เป็นลิงก์ไปยังวิกิพีเดียภาษาอังกฤษ

การแสดงความคิดเห็นคือการแทรกบรรทัดของฟอร์ม:

('prefix', 'URL format string', 1, 0)

ลงในตาราง interwiki

แถวเดียว

ผู้ใช้ขั้นสูงอาจใช้บรรทัดคำสั่งเดียว ดังต่อไปนี้:

  • มายเอสคิวเอล และ โพสต์เกรสคิวเอล
เวอร์ชันมีเดียวิกิ:
1.10 – 1.16
INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans) VALUES ('w', 'https://en.wikipedia.org/wiki/$1', 1, 0);

เวอร์ชันใหม่ของมีเดียวิกิจำเป็นต้องใช้ฟิลด์พิเศษบางอย่าง เช่น iw_wikiid

INSERT INTO interwiki (iw_prefix, iw_url, iw_api, iw_local, iw_trans, iw_wikiid) 
VALUES ('w', 'https://en.wikipedia.org/wiki/$1', 'https://en.wikipedia.org/w/api.php', 0, 1, '');

ส่งออก, เพิ่ม, นำเข้าอีกครั้ง

Alternatively, you can use the following multi-step process, which exports the interwiki table, adds a line, then re-imports it:

  • Export the database table interwiki
  • add to the end of the table a line of the following form (using English wikipedia as an example):
('w', 'https://en.wikipedia.org/wiki/$1', 1, 0);
In the above code, the semicolon ';' as seen, MUST be at the end of the table. At the end of any other line within that table Only has ','.
  • Import the database table interwiki

ทดสอบ

ทดสอบการกำหนดค่า:

  • ไปที่เว็บไซต์ของคุณ,
  • สร้างบทความ ด้วยเนื้อหาดังต่อไปนี้:
    [[w:Wikipedia:Village pump|]]
  • This should display a link to the 'Village pump' page on en.Wikipedia.org (the url https://en.wikipedia.org/wiki/Wikipedia:Village_pump)

Field documentation

Further information: Manual:Interwiki table


ทิปสำหรับผู้ดูแลระบบโครงข่าย: Several help pages link to MediaWiki.org's Manual namespace. To make these links work on your local wiki, add an interwiki link with iw_prefix=manual and iw_url=http://www.mediawiki.org/wiki/Manual:$1


ทิปสำหรับผู้ดูแลระบบโครงข่าย: $wgTranscludeCacheExpiry in your LocalSettings.php should be set if changes in the transcluded wiki are done. Alternatively, you can flush the table transcache on your local wiki.


Interwiki links to other languages

Interwiki links to other languages

If you have installed a Wiki family , you can link from an article in English to an article in German (if you have a German project, too). You can set up MediaWiki to show those links in the sidebar, just below the toolbox.

In your filesystem, there is a subfolder of your MediaWiki installation, called "languages". Go there and have a look at Names.php as it contains a list of known languages and their prefixes. E.g. you want to add your German project, search Names.php for "Deutsch" and note the prefix "de".

If you know the "right" prefix, edit your database by adding a new line to table interwiki:

iw_prefix language-prefix (e.g. "de" for German), which is listed in Names.php
iw_url URL to your wiki-project (e.g. http://de.example.org/index.php/$1)
iw_local same as above "Adding More"
iw_trans same as above "Adding More"

Now, you can link an article to the same in other languages. Adding [[de:Hauptseite]] on your English Main_Page will create a link "Deutsch" below the toolbox, which leads to the Main_Page of the German wiki (Hauptseite).

Note, that this link is shown in Sidebar's section, only, and not inside of the article. If you want to create a link inside of the text, you have to add a colon previous to the prefix: [[:de:Hauptseite]] or set $wgInterwikiMagic to false.

Exporting the interwiki table from a wiki

The following JavaScript code performs the API query to retrieve the interwiki map of an existing wiki, then displays the SQL INSERT statements to fill the interwiki table on a new wiki. You run it for example by injecting the code through your browser's developer tools, or by placing it inside Special:MyPage/skinname.js and previewing.

function ExtractInterwikiMapTable() {
	$.getJSON(mw.config.get('wgScriptPath') + '/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json', function(data) {
		var iw_prefix, iw_url, iw_local, iw_api, re_escape = /(')/g, result = '';
		for (var i = 0, iwm = data.query.interwikimap; i < iwm.length; i++) {
			iw_prefix = "'" + iwm[i].prefix.replace(re_escape, '\\$1') + "'";
			iw_url = "'" + iwm[i].url.replace(re_escape, '\\$1') + "'";
			iw_local = (typeof iwm[i].local == 'string') ? '1' : '0';
			iw_api = "'" + (iwm[i].iw_api || '').replace(re_escape, '\\$1') + "'";
			result += 'INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans, iw_api) VALUES ('+iw_prefix+', '+iw_url+', '+iw_local+', 0, '+iw_api+');\n'
		}
		$('<textarea style="width:800px;height:400px;"/>').val(result).appendTo(document.body);
	});
}

$(ExtractInterwikiMapTable);

See also