Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Template Modifications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
A Neater Google Adsense After First Post Details »»
A Neater Google Adsense After First Post
Version: 1.00, by ShawneyJ ShawneyJ is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Category: Mini Mods - Version: 4.0.5 Rating:
Released: 05-05-2010 Last Update: Never Installs: 190
Template Edits
Re-useable Code Translations  
No support by the author.

Ok, so i haven't found any google adsence products for vb 4 yet that sit neatly under your first post only, on every page. Credits to Miko and my self for a few tiny edits.

How To Install
Step.1:
GoTo Postbit Templates>>open postbit_legacy and add at the very bottom:

Code:
<vb:if condition="$post['isfirstshown']">
<li class="firstpost_advert_container"><div class="firstpost_advert">
      REPLACE THIS WITH YOUR ADSENSE CODE HERE
</div>
</li>
</vb:if>

Step.2:
GoTo CSS Templates>>open additional.css and add this code:

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

.firstpost_advert {
    with: 100%;
    background: #F1F1FA;
    border: 1px solid #fff;
    min-height: 90px;
    margin: 0;
    padding: 7px;
    text-align: center;
    vertical-align: middle;
}
Feel free to customize to your needs, i had to mess around to suit my custom style. I changed the min-height to 90px for a neater look for 728x90 ads and changed margin-bottom: to 18px. But how the code is above is perfect for Vbulletin 4 Default.
DEMO: Teen Forums
Please Note: im not a coder, i just wanted to share this with others, its VERY easy to add to your styles and looks neat. Good Luck.
This coding is also different than Mod Version: 1.00, by Allan. You shouldn't have any problems with this and it will do you till a product version comes out.

Screenshots

File Type: jpg Neater Google Adsense After First Post.jpg (83.6 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
5 благодарности(ей) от:
acmalin927, farru, sodasusu, SolidSnakeLive, StormBreaker

Comments
  #82  
Old 05-29-2014, 07:47 PM
409industries 409industries is offline
 
Join Date: Jan 2008
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
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 View Post
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.
Reply With Quote
  #83  
Old 05-31-2014, 05:00 AM
jacobin jacobin is offline
 
Join Date: May 2013
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 !
Reply With Quote
  #84  
Old 05-31-2014, 03:11 PM
409industries 409industries is offline
 
Join Date: Jan 2008
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jacobin View Post
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
Reply With Quote
  #85  
Old 06-01-2014, 01:58 AM
jacobin jacobin is offline
 
Join Date: May 2013
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by 409industries View Post
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 ??
Reply With Quote
  #86  
Old 06-01-2014, 10:16 AM
ramesh_umk3 ramesh_umk3 is offline
 
Join Date: Jul 2010
Location: Earth
Posts: 194
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Refer this post https://vborg.vbsupport.ru/showpost....8&postcount=74
ads are showed only in 1 post of a page
Reply With Quote
  #87  
Old 06-01-2014, 06:27 PM
409industries 409industries is offline
 
Join Date: Jan 2008
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jacobin View Post
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
Reply With Quote
  #88  
Old 08-06-2015, 06:49 PM
Vintum Vintum is offline
 
Join Date: Jan 2013
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04897 seconds
  • Memory Usage 2,326KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (2)bbcode_html
  • (1)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (8)post_thanks_box
  • (5)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (1)postbit_attachment
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete