vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   Mini Mods - A Neater Google Adsense After First Post (https://vborg.vbsupport.ru/showthread.php?t=241944)

409industries 05-29-2014 07:47 PM

Quote:

Originally Posted by tbworld (Post 2499986)
See ... Admin Control Panel --> Plugins and Products (Sidebar Menu) --> Add New Plugin.

Product: vbulletin
Hook Location: postbit_display_complete
Title: Postbit Post-Per-Page Counter <-- or whatever
Execution Order: 5

Plugin PHP Code:
PHP Code:

// Hook: postbit_display_complete 
if (THIS_SCRIPT == 'showthread'

    global 
$tbworld_postbit_postcount
    
vB_Template::preRegister('postbit_legacy',array('tbworld_postbit_postcount' => ++$tbworld_postbit_postcount));         


Plugin is Active : Yes

This is just a simple counter that counts post per page.

Quote:

Originally Posted by tbworld (Post 2499989)
So what should be happening is that in the "islastshown" conditional, I have added an additional check to see if the post count on that page is equal or greater than 3. If it is not then do not show the ad. Simple.

Brilliant! This is working perfectly. :up:

Until now, I have not used plugins in this manner. I've tested this in a thread, and have verified that if there were less than 3 posts only the single ad was shown. For anyone else considering making their ads work the way mine here, here's the complete code below.

These are my conditions:

1) The ads will ONLY be shown to unregistered / guest users and a couple other groups - as indicated by the <vb:if condition="is_member_of($bbuserinfo,1,3,4,8) section

2) There are TWO Google AdSense ads created, "vBulletin Forum Ad after First Post" which is shown after the opening post and "vBulletin Forum Ad Before Last Post" which is shown ONLY in a thread if there are 3 posts.

In postbit_legacy:

HTML Code:

<vb:if condition="is_member_of($bbuserinfo,1,3,4,8) AND $post['isfirstshown']">
<li class="firstpost_advert_container"><div class="firstpost_advert">
<vb:literal>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- vBulletin Forum Ad after First Post -->
<ins class="adsbygoogle"
    style="display:inline-block;width:728px;height:90px"
    data-ad-client="ca-pub-***************"
    data-ad-slot="**********2">
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</vb:literal>
</div>
</li>
</vb:if>

<vb:if condition="is_member_of($bbuserinfo,1,3,4,8) AND $post['islastshown'] AND $tbworld_postbit_postcount >= 3">
<li class="lastpost_advert_container"><div class="lastpost_advert">
<vb:literal>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- vBulletin Forum Ad Before Last Post -->
<ins class="adsbygoogle"
    style="display:inline-block;width:728px;height:90px"
    data-ad-client="ca-pub-************"
    data-ad-slot="*************">
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</vb:literal>
</div>
</li>
</vb:if>

Also, ad the "containers" that will show the ads in the threads (add this to additional.css in your style). Your border colors and sizes may vary.

HTML Code:

.firstpost_advert_container {
    clear: both;
    display: block;
    float: left;
    margin-bottom: 12px;
    position: relative;
    width: 100%;
    border: 1px solid #666666;
}

.firstpost_advert {
    with: 100%;
    background: #666666;
    border: 1px solid #666666;
    min-height: 90px;
    margin: 0;
    padding: 7px;
    text-align: center;
    vertical-align: middle;
}

.lastpost_advert_container {
    clear: both;
    display: block;
    float: left;
    margin-bottom: 12px;
    position: relative;
    width: 100%;
    border: 1px solid #666666;
}

.lastpost_advert {
    with: 100%;
    background: #666666;
    border: 1px solid #666666;
    min-height: 90px;
    margin: 0;
    padding: 7px;
    text-align: center;
    vertical-align: middle;
}

Lastly, in order for the part where only threads with several replies will show BOTH the firstpost_advert and the lastpostadvert, add the plugin that tbworld provided above.

jacobin 05-31-2014 05:00 AM

Good evening [mornig]

I love the mod greatly however i have a problem with it .. It dispaly the same AD after every single post.

Can anybidy help with that ...THx in advance !

409industries 05-31-2014 03:11 PM

Quote:

Originally Posted by jacobin (Post 2500203)
Good evening [mornig]

I love the mod greatly however i have a problem with it .. It dispaly the same AD after every single post.

Can anybidy help with that ...THx in advance !

You may need to make multiple ad units via the Google AdSense control panel

Content > Ad units > New ad unit

jacobin 06-01-2014 01:58 AM

Quote:

Originally Posted by 409industries (Post 2500251)
You may need to make multiple ad units via the Google AdSense control panel

Content > Ad units > New ad unit

I do have different Ad untis, what I am saying...The AD banner is displaying after each and every single post... I thought it was for One time AFTER the frist post ??

ramesh_umk3 06-01-2014 10:16 AM

Refer this post https://vborg.vbsupport.ru/showpost....8&postcount=74
ads are showed only in 1 post of a page

409industries 06-01-2014 06:27 PM

Quote:

Originally Posted by jacobin (Post 2500289)
I do have different Ad untis, what I am saying...The AD banner is displaying after each and every single post... I thought it was for One time AFTER the frist post ??

Yeah it should just be a single ad after the first post. Double check the code in postbit_legacy and additional.css

Vintum 08-06-2015 06:49 PM

Just in case anyone else is having trouble like I was with this on vbulletin 4.2.2, this wasn't working for me and I spent a good while trying to figure out why. Turns out the problem was I was using the wrong template.

I was using "postbit_legacy" as all instructions said to use. but I needed to just use "postbit".

After adding the code to "postbit" template, and then also changing the plugin mentioned above to reflect the same template - it now works brilliantly for me.

So, if your having trouble, try using the "postbit" template instead.


All times are GMT. The time now is 10:51 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01243 seconds
  • Memory Usage 1,754KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete