Extension:Amazon

From MediaWiki.org
Jump to: navigation, search

Script error Script error


MediaWiki extensions manual
Crystal Clear action run.png
Amazon

Release status: experimental

Implementation Tag
Description This (simple) extension could be used for your booksources response page to offer the requested books via Amazon. The extension will output the given Amazon Affiliate Code.
Author(s) Anonymous
License No license specified
Download see below

Translate the Amazon extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

This (simple) extension could be used for your booksources response page to offer the requested books via amazon.

The extension will output the given Amazon Affiliate Code.

Installation[edit | edit source]

Create a new file in your extensions folder, named Amazon.php with the following content:

<?php
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/Amazon.php");

$wgExtensionFunctions[] = "wfAmazon";
 
function wfAmazon() {
	global $wgParser;
 
	$wgParser->setHook( "amazon", "renderAmazon" );
}
 
# The callback function for converting the input text to HTML output
function renderAmazon( $input ) {
	# Your Amazon Partner ID    # <<<<< EDIT HERE <<<<<
	$partner = "EDIT HERE";
 
	# Building the code
	$output = '<iframe src="http://rcm-de.amazon.de/e/cm?t=' . $partner. '&o=3&p=8&l=as1&asins=' . htmlspecialchars( $input ) . '&fc1=000000&IS2=1&lt1=_blank&lc1=0000ff&bc1=000000&bg1=ffffff&f=ifr" style="width:120px;height:240px;"></iframe>';
 
	return $output;
}

Give your Amazon Affiliate Partner ID to the variable $partner ("EDIT HERE").

If you want to use other code than this, replace it, but remember to replace your partner id in the amazon code with the variable $partner and most important replace the ISBN (ASIN) with the variable $input.

Open your LocalSettings.php, and insert at the end of file:

require_once ("extensions/Amazon.php");

You can then create a page Project:Booksources (The Booksources must be replaces with the translated word of your site language; "Buchhandlungen" for example in German MediaWikis) with the following content:

{{MediaWiki:Booksourcetext}}

<amazon>MAGICNUMBER</amazon>

Usage[edit | edit source]

Afterwards the call to Special:Booksources/ISBNNUMBER will end up to the above mentioned page with same layout as the original but displaying your Amazon affiliate code.

See Also[edit | edit source]