duandunzhuo3234 2012-08-13 12:29
浏览 70
已采纳

在MediaWiki上使用广告和横幅[关闭]

How do I add a banner (728x90) or ads using Google's DoubleClick for Publishers (DFP) on the header and footer sections of all pages in MediaWiki?

Please any one help me.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • drq1257 2012-08-16 12:29
    关注

    There are a number of existing advertisement extensions for MediaWiki that may suit your needs, or at least serve as examples of how it can be done.

    There are a few different ways to inject ad banners into a MediaWiki skin:

    • Edit the skin template itself (e.g. skins/Vector.php for the Vector skin) and add the banner code in a suitable location. This is a fairly quick and easy solution, but suffers from the problem that you'll need to redo it every time you upgrade MediaWiki (or upgrade your skin, if you're using a non-standard one).

    • Find a suitable hook to inject the banner code into the skin. If you're just doing this for your own wiki, you can simply write the hook code directly into your LocalSettings.php (or into a separate PHP file that you include from there, if you prefer), but you could also turn it into a full MediaWiki extension (which basically just means, at a minimum, putting it in a separate file and adding a bit of boilerplate code).

      Alas, finding the right hook for the job may not always be trivial. For injecting ads into the sidebar, the SkinBuildSidebar hook may be convenient; SkinAfterContent might work for footer ads, and for top ads, you could maybe (ab)use the SiteNoticeAfter hook.

    • Create a parser tag extension that allows you to add a custom tag like <adshere/> to your pages to inject the ad banner code at that location. Straightforward, but requires you put the tag on any page that you want ads on (or in an interface message, if you can find a suitable one; tip: try appending the parameter uselang=qqx to URLs to see which messages are used where).

    • Find a suitably located interface message which is treated as raw HTML, and put your ad code there directly. Alas, there aren't many such messages, and the trend is towards getting rid of the few that are left.

    • For ads that can be injected with JavaScript only, you can simply put the code in MediaWiki:Common.js (or in the appropriate skin-specific JS page).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题