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

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

报告相同问题?

悬赏问题

  • ¥15 python变量和列表之间的相互影响
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)