allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

Amazon Associate Ads

天下维客,你可以修改的网络知识库

Jump to: navigation, search
Template:If
Type: {{{type}}}
Maturity: {{{maturity}}}
MediaWiki: 1.8.2 以上
Version: 1
Last Update: January 22, 2007
Description: 帮助你在页面上添加亚马逊合作广告.
MediaWiki extensions

目录

什么是亚马逊合作广告?

从 1996开始, Amazon.com就进行会员市场项目. 通过投放该广告,你将获得交易额 8.5% 作为报酬.

你可以在这了解到更多信息[1].

该扩展有一个修改版: [2]

作用

允许你添加任意类型的亚马逊合作广告到你的WIKI页面.

安装

  • 申请一个亚马逊合作广告会员账号, 然后建立一个链接.
  • 以该链接的代码建立一个模版文件.

例如广告代码为:

<script type="text/javascript"><!--
  amazon_ad_tag = "your_ad_tag";  amazon_ad_width = "728";  amazon_ad_height = "90";//--></script>
<script type="text/javascript" src="http://www.assoc-amazon.com/s/ads.js"></script>

为了你的代码安全, 建立一个亚马逊合作广告模版. 例如命名为 Template:728x90_am . 每个模版将必须设置保护为管理员权限. 然后你可以象这样 {{728x90_am}}调用显示该广告

  • 切记去除以下代码:
<script type="text/javascript"><!--
  • 切记去除还有以下代码:
//--></script>
 <script type="text/javascript" src="http://www.assoc-amazon.com/s/ads.js"></script>
  • 然后放到 <amazon> </amazon> 标记之间, 例如:
<amazon>amazon_ad_tag = "your_ad_tag";  amazon_ad_width = "728";  amazon_ad_height= "90";</amazon>
  • 不要在<amazon></amazon> 标记之间留任何空格

代码

文件名 "extensions/AmazonExt.php":

拷贝下面代码,生成 AmazonExt.php文件

<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * Amazon WikiMedia extension
 *
 * Firstly create a file called AmazonExt.php and place this in the extensions
 * directory - copy all this code to that file.
 * To activate the extension, include it from your LocalSettings.php
 * with: require_once 'extensions/AmazonExt.php';
 *
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt. If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * 
 * <code>
 * <amazon> 
 * amazon_ad_tag = "your_ad_tag";  amazon_ad_width = "468";  amazon_ad_height = "60";
 * amazon_ad_logo = "hide"; amazon_ad_link_target = "new";  amazon_ad_border = "hide";
 * </amazon>
 * </code>
 */

/*
 * @todo Document 
 */
$wgExtensionFunctions[] = 'wfAmazon';

/**
 * @todo Document
 */
function wfAmazon()
{
    global $wgParser;

    // registers the <amazon> extension with the WikiText parser
    $wgParser->setHook('amazon', 'renderAmazon');
}

/**
 * @todo Document
 */
function renderAmazon($input, $argv)
{
    $output  = '<script type="text/javascript">/* <![CDATA[ */';
    $output .= $input;
    $output .= '/* ]]> */</script>';
    $output .= '<script type="text/javascript"';
    $output .= ' src="http://www.assoc-amazon.com/s/ads.js">';
    $output .= '</script>';

    return $output;
}
?>

激活

修改LocalSettings.php, 在接近底部的地方添加:

require_once 'extensions/AmazonExt.php';

演示

This extension is in use on http://www.Wikistock.com

  • Click here to see it in use:[3]
  • To see the template in use on Wikistock.com click here:[4]

引用

http://wiki.000112.com/modules/mediawiki/index.php/Extension:Amazon_Associate_Ads

Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币