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

在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).

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

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?