dbtlr / dfp-bundle
Symfony2 Bundle for integrating with the Google DFP Ad Network.
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 6
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=5.3.2
- symfony/symfony: >=2.0,<2.4-dev
This package is not auto-updated.
Last update: 2022-02-01 12:26:56 UTC
README
Installation Instructions
- Download NodrewDfpBundle
- Configure the Autoloader
- Enable the Bundle
- Add your Google DFP Publisher Id
Step 1: Download NodrewDfpBundle
Ultimately, the NodrewDfpBundle files should be downloaded to the
vendor/bundles/Nodrew/Bundle/DfpBundle
directory.
This can be done in several ways, depending on your preference. The first method is the standard Symfony2 method.
Using the vendors script
Add the following lines in your deps
file:
[NodrewDfpBundle]
git=http://github.com/nodrew/NodrewDfpBundle.git
target=/bundles/Nodrew/Bundle/DfpBundle
Now, run the vendors script to download the bundle:
$ php bin/vendors install
Using submodules
If you prefer instead to use git submodules, then run the following:
$ git submodule add http://github.com/nodrew/NodrewDfpBundle.git vendor/bundles/Nodrew/Bundle/DfpBundle $ git submodule update --init
Step 2: Configure the Autoloader
// app/autoload.php $loader = new UniversalClassLoader(); $loader->registerNamespaces(array( // ... 'Nodrew' => __DIR__.'/../vendor/bundles', ));
Step 3: Enable the bundle
Finally, enable the bundle in the kernel:
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Nodrew\Bundle\DfpBundle\NodrewDfpBundle(), ); }
Step 4: Add your Google DFP Publisher Id
# app/config/config.yml nodrew_dfp: publisher_id: [publisher_id]
Step 5: Add Control Code Placeholder to layout
This placeholder comment needs to be added to the head of your layout. It is automatically replaced with the proper Google DFP code, when ads are used on the given page.
// app/views/base.html.twig <head> ... <!-- NodrewDfpBundle Control Code --> </head>
Using Ad Units
In page unit.
To use a standard in page ad unit, add the following to your template:
{{ dfp_ad_unit('some/campaign', [300, 250]) }}
The appropriate control codes will be added to the header, if everything was done correctly during setup.
Out of page unit.
If you're looking to do a DFP out of page unit, such as an interstitial, or a skin, then use this code. It is much similar, just without the size attached to it.
{{ dfp_oop_ad_unit('some/campaign') }}
The appropriate control codes will be added to the header, if everything was done correctly during setup.