Thread:Project:Support desk/get page id in different languages/reply (3)

When you switch languages, you click a link. There is no sql query involved at all.

$html = ''; foreach( $langlinks as $langlink ) { // array( 'll_lang' => 'en', 'll_title' => 'Robert de Niro' ) $url = $interwikis[ $langlink['ll_lang'] ]['iw_url]; // "http://en.wikipedia.org/wiki/$1" $url = str_replace( '$1', wfUrlEncode( $langlink['ll_title'] ) ); // "http://en.wikipedia.org/wiki/Robert_de_Niro" $html .= 'English'; }
 * You view article on http://ru.wikipedia.org/wiki/Де_Ниро,_Роберт
 * MediaWiki extracts namespace and title of this page (page_namespace=0; page_title='Де_Ниро,_Роберт')
 * MediaWiki get page-table row and shows article
 * MediaWiki knows page_id from page-table row and gets langlinks
 * MediaWiki now has a list of langlinks for this page. For each of them it knows the full pagenames( : "Robert De Niro") and the interwiki code( : "en") where that page exists. Now MediaWiki queries the interwiki information for all interwiki links (for example: )
 * Now, simplified, it goes over a foreach loop in PHP:

// In the sidebar: echo $html;

Now you click the link to en.wiki, it does not query for the page_id of the page on the other wiki.