snapshotpl/zf-snap-google-adsense 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

snapshotpl/zf-snap-google-adsense

Composer 安装命令:

composer require snapshotpl/zf-snap-google-adsense

包简介

Google Adsense view helper for Zend Framework 2

README 文档

README

Google AdSense view helper for Zend Framework 2

Module helps to manage yours AdSense units on page. Keep them all in one place and use renderers!

The simplest usage

Add ad unit (one or more) and publisher ID (you can find it here) to your config:

return array(
  'zf-snap-google-adsense' => array(
    'publisher-id' => 'pub-1234567890123456',
    'ads' => array(
      'home-page' => array(
        'id' => 1234567890,
        'size' => '336x280',
      ),
    ),
  ),
);

And then render ad in your view by view helper. You can use googleAdsense or adsense name:

echo $this->adsense('home-page');

That's all! In default adsense use asynchronous code. You can change it by using predefined view renderers.

How to install?

Via composer.json

{
  "require": {
    "snapshotpl/zf-snap-google-adsense": "1.*"
  }
}

Renderers

You can use renderes (by implements ZfSnapGoogleAdSense\View\Helper\Renderer\RendererInterface) to render your ads. In default module provides simple view renderer with very useful views:

  • asynchronous (default): official asynchronous script,
  • synchronous: official synchronous script,
  • placeholdit: fake placeholer is using placehold.it service to generate image, perfect for dev or test eviroments, you can customize it, to details see config/module.config.php and overwrite options,
  • html: generates html div, perfect for dev or test eviroments, you can customize it, to details see config/module.config.php and overwrite options,

To add own view to view render create view (in view you can use ad property which it's instance of \ZfSnapGoogleAdSense\Model\AdUnit by default) add it to view_manager with prefix zf-snap-google-adsense-renderer-view-*:

return array(
  'view_manager' => array(
    'template_map' => array(
      'zf-snap-google-adsense-renderer-view-customview' => __DIR__ . '/my-awesome-custom-view.phtml',
    ),
  ),
);

To change current view renderer pass view name to renderer option:

return array(
  'zf-snap-google-adsense' => array(
    'renderer' => 'zf-snap-google-adsense-renderer-view-customview',
  ),
);

If you wrote your own renderer pass intance name from service_manager. You can also set custom parameters into view. To see how it works look into renderers array in config/module.config.php and view renderers source.

Options

ads defines ad units

  • id (required): Ad ID,
  • size (required): You can define size by string or array,
  • type: content and link. Content unit is default. You can use constats or strings,
  • name: It's used in custom renderes (placeholdit and html). If name is not defined, ad gets name by key name,
return array(
  'zf-snap-google-adsense' => array(
    'ads' => array(
      'link-ad-by-constat' => array(
        'id' => 1234567890,
        'size' => '336x280',
        'type' => \ZfSnapGoogleAdSense\Model\AdUnit::TYPE_LINK,
      ),
      'link-ad-by-string' => array(
        'id' => 1234567890,
        'size' => array(
          'width' => 336,
          'height' => 280,
        ),
        'type' => 'link',
      ),
      'content-ad' => array(
        'id' => 1234567890,
        'size' => '336x280',
        'type' => \ZfSnapGoogleAdSense\Model\AdUnit::TYPE_CONTENT,
        'name' => 'Content ad under header',
      ),
    ),
  ),
);

enable if equals false, than disable ads on page.

return array(
  'zf-snap-google-adsense' => array(
    'enable' => false,
  ),
);

publisher-id (required) publisher ID - you can find it here

unit-limit limits ads on page. Default values:

return array(
  'zf-snap-google-adsense' => array(
    'unit-limit' => array(
      AdUnit::TYPE_CONTENT => 3,
      AdUnit::TYPE_LINK => 3,
    ),
  ),
);

统计信息

  • 总下载量: 5.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固