floxum / ad-units
Ad units for your Flarum forum.
Package info
gitlab.com/floxum/extensions/flarum-ext-ad-units
Type:flarum-extension
pkg:composer/floxum/ad-units
Requires
- flarum/core: ^2.0
Requires (Dev)
- flarum/phpstan: ^2.0
- flarum/testing: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Flarum 2.x extension that places ad units on your forum: in the header, the side navigation, between posts, above the first post of a discussion, in the discussion sidebar and in the footer.
This is the Flarum 2.x continuation of davwheat/flarum-ext-ads by David Wheatley.
Installation
composer require floxum/ad-units:"*"
Moving from davwheat/flarum-ext-ads
davwheat/flarum-ext-ads only supports Flarum 1.x. When you upgrade your forum to Flarum 2.x, Ad Units takes over its configuration: the enabled locations, all HTML and JavaScript code, the AdSense publisher ID, custom script URLs, the between-posts settings and the groups holding the "Hide advertisements" permission. Values you already set in Ad Units are never overwritten.
- Before upgrading, keep the old extension's data. You can disable davwheat Ad Units, but do not uninstall it with its data (purge): its settings are what Ad Units copies.
- As part of the Flarum 2.x upgrade, remove the old package, which cannot be installed on 2.x:
composer remove davwheat/flarum-ext-ads composer require floxum/ad-units:"*"and enable Ad Units in the admin panel. The configuration is copied when the extension is enabled.
The davwheat-ad* CSS classes are still applied to every ad, so custom CSS targeting them keeps working.
"Between posts" now places ads after post N, 2N, 3N…, and the ad directly below the opening post has its own location, "below the first post". davwheat-ads always put a between-posts ad there, so when between-posts ads were enabled, that location is enabled with the same code during the move.
Usage
Head to the extension's settings page, switch on the locations you'd like and paste your ad code into the boxes that appear.
- AdSense: set your publisher ID and paste only the
<ins>tag of each ad unit into the HTML box. <script>tags in the HTML boxes are not executed; put that code in the JavaScript box of the same location instead.- Members of groups with the Hide advertisements permission (including all admins) never see ads. Test in a private window.
Updating
composer update floxum/ad-units:"*"
php flarum migrate
php flarum cache:clear