Resource icon

xF1 Guides DFP Integration into Xenforo + Adblock detection

Changed some formatting to the thread and updated the code for the Adblock message to user.

New code
CSS changes:
Added round borders
Changed background color
Goes in extra.css
CSS:
/* AdBlock Detection */
#tester {
    display:none;
}

.blockContainer { text-align: center; margin: 10px auto; clear: both; }
.noticeContainer { padding: 20px; background: #F76A07; color: #fff; border-radius: 5px; }
.noticeContainer .head { font-size: 22px; font-weight: bold; text-shadow: 1px 1px 3px #494949; }
.noticeContainer .foot { font-size: 14px; margin-top: 10px; text-shadow: 1px 1px 3px #494949; }

Adblock message changes:
Please take note of all my URL's in this and change to your URL structure.
The top area is so that the "adblock" message doesn't show on specific pages, so if you have something similar to my set up, just change the URL paths or if you don't want to do that, remove everything above and including the xen:else
Changed the color from red to orange in hopes it looks less like a "DO THIS OR ELSE" to a "Hey you, please unblock us" while still attention grabbing.
I've added links on my site to explain our ads, explain how to unblock us in their ad blockers, and our paid membership upgrades.
There are 2 sets of the message here, just like the original code I gave. Reason being, you won't tell a member to register to sign up for your paid membership and you won't tell a guest to become a premium member without being a member first.
Add this to your ad_below_top_breadcrumb:
HTML:
<xen:if is="{$requestPaths.requestUri} == '/pages/adblock/'">
<xen:elseif is="{$requestPaths.requestUri} == '/pages/about-ads/'" />
<xen:elseif is="{$requestPaths.requestUri} == '/pages/premium/'" />
<xen:elseif is="{$requestPaths.requestUri} == '/tickets/'" />
<xen:elseif is="{$requestPaths.requestUri} == '/account/upgrades'" />
<xen:else />
<xen:if is="!in_array({$contentTemplate}, array('message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'error_with_login', 'contact'))">
    <xen:if is="!{xen:helper ismemberof, $visitor, 1, 3, 4}">
        <script type="text/javascript" src="/advertisement.js"></script>
        <script type="text/javascript">
            if (document.getElementById("tester") != undefined)
                {
                    document.write(' ');
                }
            else
                {
                    document.write('<div class="messageText ugc blockContainer"><div class="noticeContainer"><div class="head">Oh noes! An ad should be here.</div><div class="foot">Ads suck, we know! We are just a small company wanting to create new, fun features for you to enjoy and the ads help keep the free amazing information on the site alive! Learn more <a href="/pages/about-ads/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">about our ads</a> or <a href="/pages/premium/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">purchase Premium</a> to remove the ads and this message. Here\'s <a href="/pages/adblock/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">how you can disable your ad blocker</a>.</div></div></div>');
                }
        </script>
    </xen:if>
    <xen:if is="!{$visitor.user_id}">
        <script type="text/javascript" src="/advertisement.js"></script>
        <script type="text/javascript">
            if (document.getElementById("tester") != undefined)
                {
                    document.write(' ');
                }
            else
                {
                    document.write('<div class="messageText ugc blockContainer"><div class="noticeContainer"><div class="head">Oh noes! An ad should be here.</div><div class="foot">Ads suck, we know! We are just a small company and the ads help to keep this treasure trove of free information alive and available to you! Please consider disabling your ad blocker or register an account to <a href="/pages/premium/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">become a Premium Member</a> where we remove the ads for you. We thank you for your support.<br />Learn how to <a href="/pages/adblock/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">disable your ad blocker</a> for just Se7enSins and find more information on the <a href="/pages/about-ads/" style="color: #fff; font-weight:bold; text-decoration: underline; text-shadow:0 0 0;">ads we serve</a>.</div></div></div>');
                }
        </script>
    </xen:if>
</xen:if>
</xen:if>



Old code
Add this to your Extra.css:
CSS:
/* AdBlock Detection */
#tester {
    display:none;
}

.blockContainer { text-align: center; margin: 10px auto; clear: both; }
.noticeContainer { padding: 20px; background: #c44; color: #fff; }
.noticeContainer .head { font-size: 22px; font-weight: bold; }
.noticeContainer .foot { font-size: 16px; margin-top: 10px; }

Add this to your ad_below_top_breadcrumb:
HTML:
    <xen:if is="!{xen:helper ismemberof, $visitor, 1, 3, 4}">
        <script type="text/javascript" src="/advertisement.js"></script>
        <script type="text/javascript">
            if (document.getElementById("tester") != undefined)
                {
                    document.write(' ');
                }
            else
                {
                    document.write('<div class="messageText ugc blockContainer"><div class="noticeContainer"><div class="head">Oh man! Ad-blocking software has been detected!</div><div class="foot">Hey, we hate ads too! However, the money from ads is used to improve site reliability and bring additional features to our users!<br />Please consider disabling your ad-block or <a href="account/upgrades" style="color: #000000; font-weight:bold">becoming a premium member</a> to hide all advertisements and this notice. Thanks!</div></div></div>');
                }
        </script>
    </xen:if>
    <xen:if is="!{$visitor.user_id}">
        <script type="text/javascript" src="/advertisement.js"></script>
        <script type="text/javascript">
            if (document.getElementById("tester") != undefined)
                {
                    document.write(' ');
                }
            else
                {
                    document.write('<div class="messageText ugc blockContainer"><div class="noticeContainer"><div class="head">Oh man! Ad-blocking software has been detected!</div><div class="foot">Hey, we hate ads too! However, the money from ads is used to keep the site functioning properly and to provide information for free!<br />Please consider disabling your ad-block or register an account and <a href="account/upgrades" style="color: #000000; font-weight:bold">become a premium member</a> where we hide the ads for you.</div></div></div>');
                }
        </script>
    </xen:if>
731Threads
2,287Messages
63,878Members
brandvisionLatest member
Back