Extension:AmazonAssociates
From MediaWiki.org
|
AmazonAssociates Release status: unknown |
|
|---|---|
| Implementation | Tag |
| Description | Allows to display Amazon books using a combination of the Amazon web service and the Amazon Associates program. |
| Author(s) | Bradford Knowlton |
| Download | see below |
AmazonAssociates is a simple extension to display amazon books using a combination of the Amazon web service and the Amazon Associates program. This is a simple tool developed by User:Bradmkjr for his wiki and he decided to share, use it as a concept and develop it to suit your needs.
Here is the PHP code:
<?php $wgExtensionFunctions[] = "AmazonAssociates"; // Extension credits that show up on Special:Version $wgExtensionCredits['parserhook'][] = array( 'name' => 'AmazonAssociates', 'author' => 'Bradford Knowlton', 'url' => 'http://www.mediawiki.org/wiki/Extension:AmazonAssociates', 'description' => 'Display Amazon books using a combination of the Amazon web service and the Amazon Associates program.' ); function AmazonAssociates() { global $wgParser; $wgParser->setHook('amazon', 'AmazonAssociate'); } function AmazonAssociate($input, $argv, $parser) { global $wgParser; $wgParser->disableCache(); //ATTENTION; DISABLE THIS LINE IF YOU ARE ON HIGH LOAD! $isbn = substr($argv['src'],0,strpos($argv['src'],'.')); $src = $argv['src']; return "<a href='<nowiki>http://www.amazon.com/gp/redirect.html%3FASIN=$isbn%26tag=<!! AMAZON PARTNER CODE !!>%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/$isbn%253FSubscriptionId=0EMV44A9A5YT1RVDGZ82</nowiki>' title='View product details at Amazon'><img src='<nowiki>http://ec1.images-amazon.com/images/P/$src</nowiki>' alt='$input' />$input</a>"; }
[edit] Installation
Save the code as AmazonAssociates.php and upload it into your extension folder.
Then add the following code to your LocalSettings.php
require_once("extensions/AmazonAssociates.php");
[edit] Usage
<amazon src='Image file name'>Book Title</amazon>
For example
<amazon src='0517226952.01._SCTHUMBZZZ_V1108549558_.jpg'>The Ultimate Hitchhiker's Guide (Deluxe Edition)</amazon>
[edit] Problems?
This code is very simple, and really doesn't do much other then output some html, shorten a string, and make it look fancy.

