idmarinas / advertising-bundle
在您的Symfony应用中展示网络广告。附带Adsense网络和通用网络,以便添加您自己的网络。
1.7.1
2024-04-18 17:19 UTC
Requires
- php: ^7.4 | ^8.0
- symfony/config: ^4.4 | ^5.4 | ^6.1 | ^7.0
- symfony/dependency-injection: ^4.4 | ^5.4 | ^6.1 | ^7.0
- symfony/event-dispatcher: ^4.4 | ^5.4 | ^6.1 | ^7.0
- symfony/http-kernel: ^4.4 | ^5.4 | ^6.1 | ^7.0
- symfony/yaml: ^4.4 | ^5.4 | ^6.1 | ^7.0
- twig/twig: ^2.12 | ^3.0
Requires (Dev)
- matthiasnoback/symfony-config-test: ^4.2 | ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^4.2 | ^5.1
- nyholm/symfony-bundle-test: ^2.0 | ^3.0
- phpunit/phpunit: ^9.5
- rector/rector: ^0.15
- symfony/phpunit-bridge: ^5.3
- symfony/test-pack: ^1.0
README
AdvertisingBundle
在您的Symfony应用中展示网络广告。附带Adsense网络和通用网络,以便添加您自己的网络。
安装
Composer
composer require idmarinas/advertising-bundle
使用方法
配置参考
# config/packages/idm_advertising.yaml idm_advertising: enable: true # Enable/disable advertising bundle. default false networks: # Required adsense: # Default configuration for AdSense Advertising type: adsense # service_network: idm_advertising.adsense # Custom service provider, ID of service enable: true # Enable/disable advertising provider client: null # "data-ad-client" ca-pub-XXXXXXX11XXX9 banners: # Banners of ads (As many as you need with the same format). Required banner_header: style: 'display:block' # style="" tag in <ins> slot: 0 # "data-ad-slot" Slot ID of Ad block 8XXXXX1 format: 'auto' # "data-ad-format" Values: "rectangle", "vertical" or "horizontal" responsive: true # "data-full-width-responsive" other_banner: style: 'display:block' slot: 0 format: 'auto' responsive: true generic: type: generic # Required service_network: 'your.service.id' # Required banners: # Required custom_zone: config: 'for your custom network banner'
在模板中使用
<!-- Code of your template --> <!-- .... --> {{ advertising_banner('adsense', 'banner_header') }} {{ advertising_banner('generic', 'custom_zone') }} <!-- .... --> <!-- Code of your template -->
第一个参数是网络名称,第二个是横幅名称。
对于最后需要打印横幅的脚本。
<!-- Before </body> tag --> <!-- This print all scripts --> {{ advertising_scripts() }} <!-- This print scripts for adsense network --> {{ advertising_scripts('adsense') }}