Help:Guide for system administrators for setting up interwiki linking

From Eugene Neighbors
(Redirected from Interwiki links)
Jump to: navigation, search
45px 50px
This page {{#ifeq:|ready|is ready to be|should be}} moved to MediaWiki.org.
Please do not move the page by hand. It will be imported by a MediaWiki.org administrator with the full edit history. In the meantime, you may continue to edit the page as normal.

{{#ifeq:|ready||}}

{{#if: Help|

{{#if:|Other languages:}} Template:H-langs:

{{#if: Help||}}|

{{#if:|Other languages:}} Template:H-langs: {{#if: Help||}}}} en:Interwiki links is an example of an interwiki link!

MediaWiki uses certain namespaces as pointers to articles on different wikis; these work by simple URL substitution, so can point to non-wiki sites just as easily. They are stored in the database, as a prefix, a URL, and a "local" flag, which is used to mark any that are "sister projects" within the same organisation, and should have certain properties enabled. In some versions, there is also a "trans" flag; leaving both of these as '0' should be safe.

Contents

Database

Remember that your actual wikidb and wikiuser name were specified by you, and are stored in LocalSettings.php.

Fire up mysql

mysql -u <wikiuser> -p

then enter your password, then,

 USE <wikidb>

example:

aaron@escargot ~ $ mysql -u wikiuser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 816 to server version: 4.0.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> USE wikidb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>

View interwiki table

The names of the tables that store information about interwiki begin with interwiki, or if you are using a table prefix, it's yourprefix_interwiki — the following assumes no table prefix.

Type interwiki<tab><tab> to see a list of interwiki related tables

mysql> interwiki
interwiki            interwiki.iw_prefix
interwiki.iw_local   interwiki.iw_url
mysql> interwiki 

The primary table is 'interwiki'.

To see how many entries there are in the table:

SELECT COUNT(*) FROM interwiki;

To see what they are:

SELECT * FROM interwiki;

See http://dev.mysql.com/doc/refman/5.1/en/retrieving-data.html for more information on retrieving data from an SQL table.


Edit interwiki table

Add your own custom

You can follow the format of the next section to create your own interwiki links to add..

bugzilla-interwiki.sql

REPLACE INTO interwiki (iw_prefix,iw_url,iw_local) VALUES
('kdebug','http://bugs.kde.org/show_bug.cgi?id=$1',0),
('mozbug','http://bugzilla.mozilla.org/show_bug.cgi?$1',0),
('gentoobug','http://bugs.gentoo.org/show_bug.cgi?$1',0);

mysql -u <username> -p <nameofyourdatabase> < <filename.sql>

mysql -u wikiuser -p wikidb < bugzilla-interwiki.sql

This does not report success when it works. If you want to double check, you have to check the interwiki table.

Use wikipedia's interwiki list

The file: maintenance/wikipedia-interwiki.sql contains data like this:

REPLACE INTO interwiki (iw_prefix,iw_url,iw_local) VALUES
('w','http://www.wikipedia.org/wiki/$1',1),
('m','http://meta.wikipedia.org/wiki/$1',1),
('meta','http://meta.wikipedia.org/wiki/$1',1),
('zu','http://zu.wikipedia.org/wiki/$1',1);

To execute this, type into your mysql:

mysql> \. /var/www/localhost/mediawiki-1.3.0/maintenance/wikipedia-interwiki.sql
Query OK, 155 rows affected (0.24 sec)
Records: 155  Duplicates: 0  Warnings: 0

mysql>  

Remember, however that if you are using a table prefix, you will need to change the file accordingly (interwiki -> myprefixinterwiki)

Opening interwiki-links in a new window

  1. Edit the Interwiki-table, the interwiki-link
  2. Add
" target="_blank

with the quotes just like that at the end of the interwiki-link.

It should look like this:

http://de.wikipedia.org/wiki/$1" target="_blank

see also: Opening external links in a new window

More MySQL help

Mysql Help

Using phpMyAdmin instead (preferred method - simpler)

If your server uses the software phpMyAdmin, you can simply select the database that uses the wiki (remember that your actual wikidb and wikiuser name were specified by you, and are stored in LocalSettings.php ), then select the table "interwiki" from the sidebar. To use the graphical interface, just select "browse" at the top and then you can opt to "insert new row" (at the bottom of the table) following the pattern established for the other items ("$1" is what will be replaced with whatever follows the interwiki prefix in your code; it will usually be at the end of the URL for the site for which you want to make a shortcut). Then click go or opt to insert another record until you are done.

Admin tips

On my MediaWiki 1.4.7, I was obliged to activate the interwiki feature by creating first an interwiki link as wiki admnistrator. Before no interwiki link was active, after they were. I could even delete the link afterward, interwiki stay active. Don't know why jdd 14:19:51, 2005-08-08 (UTC)

Do not create an interwiki prefix which is the same as an existing namespace on your wiki. I have a larger project, called "I2U2", for which the wiki is only one component, for a glossary. I wanted an interwiki link to the main page of the whole project, not just the wiki, but calling it "i2u2" produces a link to the namespace, not the local link I had hoped for. --Eric Myers 13:59, 13 June 2006 (UTC)

Interwiki links use

To use the interwiki link, simply insert where advisable

[[:iw-link:target]]

The first colon is optional here. The optional target after the right colon will replace the placeholder "$1" you have written after the URL in the database table. You will probably add here the link to the actual page within the target site.

Language links

If the iw-link is made of any language shortcut found in the Names.php file, it has a different behavior. Examples below are for the english "en" shortcut.

  • [[en:target]] placed anywhere in a page is not displayed in the page but triggers the display of the "other languages" menu on the left of the screen, with the language name shown sending to the en:target interwiki link, as defined in the database.
  • alas, any occurence of this tag triggers the appearence of the language name, so only one (for each language involved) must be inserted on the page.
  • if you want to have the link visible elsewhere in the page, you must use the [[:en:target]] variant (two colons).

N.B. interwiki language links don't work on this actual page. This kind of link is not activated (unusefull) on MediaWiki pages. You can see them in action on http://fr.susewiki.org/

Maintenance script

maintenance/wikipedia-interwiki.sql

When upgrading from a 1.2 to 1.3, your interwiki table will be created. However, it will not be updated on further upgrades.

Use_wikipedia.27s_interwiki_list shows how to use it.

Undocumented feature

Q: I'm puzzled about doing Interwiki links, the Interwiki.php is obsoleted... how do you set up interwiki links?

A: Before we can answer that, we must ask another question: do you need language links or just external interwiki links?

To set up new interwiki link prefixes, you stick them into the 'interwiki' table in the database (which is undocumented... the source code is the documentation).

  • Sample sql in the maintenance dir. Basically:
iw_prefix  iw_url  	                iw_local
fr 	   http://fr.yourdomain.tld/$1 	1
  • maintenance/interwiki.sql defines the standard prefixes
  • maintenance/wikipedia-interwiki.sql has the wikipedia language prefixes
  • set the magic global on then, and mark the local prefixes as local in the db
  • $wgInterwikiMagic = true; # Treat language links as magic connectors, not inline links
    • default is true
      • This does not appear to be the case in MediaWiki version 1.5.3. Adding this variable to LocalSettings.php solved this.
  • The 'iw_local' field in the interwiki table is currently only used for the redirect feature. Inline or 'other langues' box is determined by whether the prefix is in the array of language codes/names defined in the language file ($wgLanguageNames).

Questions and Answers

Q: Even after modifying the Names.php file to alter one of the existing language prefixes to allow a different (non-language) interwiki link to be created with its prefix instead, and after adding the (non-language) prefix and link successfully to the 'interwiki' table, the new (non-language) prefix cannot successfully be used inside of a wiki page (it appears instead as an "other language" and also does not appear in the main body of the wiki page where the prefix code has been placed). (The variable $wgInterwikiMagic is not present in my LocalSettings.php file, and adding it to be true (or false) did not help.)

this tip don't works, no modification in the local interwiki table is taken into account (deleting a line don't disallow the link!) jdd 11:20:29, 2005-08-07 (UTC)

Can anybody help? 195.37.79.168 10:18, 1 August 2006 (UTC)


Next page: Custom skins >

Creative Uses

Bugzilla links

bugzilla-interwiki.sql

See it in action at Add_your_own_custom


See also

{{#if: Help|{{#if: Help|Template:Ph:Guide for system administrators for setting up interwiki linking}}

Links to other help pages

Help contents (all help pages)
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s:
Versions of this help page (for other languages see below)
Meta | Wikinews | {{#if:|{{#if:Wikipedia|Wikipedia|w:Help:Guide_for_system_administrators_for_setting_up_interwiki_linking#}}|{{#if:Wikipedia|Wikipedia|w:Help:Guide_for_system_administrators_for_setting_up_interwiki_linking}}}}http://en.wikipedia.org{{#if:%7C/wiki/Help:Guide_for_system_administrators_for_setting_up_interwiki_linking#%7C/wiki/Help:Guide_for_system_administrators_for_setting_up_interwiki_linking}} | Wikiquote | Wiktionary
Links to this page from Meta (int) Meta (ext) Wikipedia MediaWiki
Reading
Go | Search | Stop words | URL | Namespace | Page name | Section
Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
Logging in and preferences
Logging in | Preferences | User style
Editing
Advanced editing | Editing FAQ | Editing toolbar | Export | Import
Editing tips and tricks | Editing shortcuts
Tracking changes
Recent changes (enhanced) | Related changes | Watching pages | Diff
Page history | Edit summary | User contributions | Minor edit | Patrolled edit
Style & formatting
Wikitext examples | Wikitext reference | Reference card
HTML in wikitext | HTML elements
List | Table | Sorting
Special input and output
Inputbox | Special characters | Displaying a formula | Images and other uploaded files | EasyTimeline
Advanced functioning
Template | Advanced templates | Parser function | ParserFunctions | Parameter default | Variable | Magic word | System message | Substitution
Array | Calculation
Page management
Starting a new page | Renaming (moving) a page | Maintenance | Merging and moving pages | Protecting pages
Resolving disputes | Deleting a page
Special pages
Talk page | Testing | Sandbox
Lists of resources
Lists of Categories | Copyrights | Infobox
Redirect | Reference Desk | Shortcuts | Stub types

Other languages: Template:H-langs:Interwiki links |{{#if: Help|Template:Ph:Guide for system administrators for setting up interwiki linking}}

Links to other help pages

Help contents (all help pages)
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s:
Versions of this help page (for other languages see below)
Meta | Wikinews | {{#if:|{{#if:Wikipedia|Wikipedia|w:Help:Guide_for_system_administrators_for_setting_up_interwiki_linking#}}|{{#if:Wikipedia|Wikipedia|w:Help:Guide_for_system_administrators_for_setting_up_interwiki_linking}}}}http://en.wikipedia.org{{#if:%7C/wiki/Help:Guide_for_system_administrators_for_setting_up_interwiki_linking#%7C/wiki/Help:Guide_for_system_administrators_for_setting_up_interwiki_linking}} | Wikiquote | Wiktionary
Links to this page from Meta (int) Meta (ext) Wikipedia MediaWiki
Reading
Go | Search | Stop words | URL | Namespace | Page name | Section
Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
Logging in and preferences
Logging in | Preferences | User style
Editing
Advanced editing | Editing FAQ | Editing toolbar | Export | Import
Editing tips and tricks | Editing shortcuts
Tracking changes
Recent changes (enhanced) | Related changes | Watching pages | Diff
Page history | Edit summary | User contributions | Minor edit | Patrolled edit
Style & formatting
Wikitext examples | Wikitext reference | Reference card
HTML in wikitext | HTML elements
List | Table | Sorting
Special input and output
Inputbox | Special characters | Displaying a formula | Images and other uploaded files | EasyTimeline
Advanced functioning
Template | Advanced templates | Parser function | ParserFunctions | Parameter default | Variable | Magic word | System message | Substitution
Array | Calculation
Page management
Starting a new page | Renaming (moving) a page | Maintenance | Merging and moving pages | Protecting pages
Resolving disputes | Deleting a page
Special pages
Talk page | Testing | Sandbox
Lists of resources
Lists of Categories | Copyrights | Infobox
Redirect | Reference Desk | Shortcuts | Stub types

Other languages: Template:H-langs:Interwiki links }}

Personal tools