Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2014, 04:58 PM
chefy chefy is offline
 
Join Date: Jul 2012
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Prevent AdSense on not_logged_no_permission pages?

If for example a guest is trying to access a thread posted on a members-only forum he will get an error message that says:

Quote:
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

blah blah blah...
I want to prevent AdSense to be shown on those specific not_logged_no_permission pages, how I can do that please? Thanks!
Reply With Quote
  #2  
Old 05-06-2014, 09:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is that the ad templates (and header and footer templates) are rendered before you know if there is a permission problem. I suppose it's possible to re-render those templates in the case of an error (maybe using the error_nopermission hook), but it might take some code. At the minimum you'd need a "global" statement for any variables that the header or footer uses.

I guess another approach would be to do a str_replace() on the $header or $footer variables to remove the AdSense, but you'd have to figure out what you could match to do that.
Reply With Quote
Благодарность от:
chefy
  #3  
Old 05-06-2014, 10:43 PM
chefy chefy is offline
 
Join Date: Jul 2012
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks God I'm not using the ad templates, the AdSense code is directly attached to the navbar template. Is there any conditional I can use there against not_logged_no_permission pages?
Reply With Quote
  #4  
Old 05-06-2014, 11:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might be able to create a plugin using hook error_nopermission and code like:
Code:
$show['hide_adsense'] = true;
then in the template surround your adsense code with:
Code:
<if condition="!$show['hide_adsense']">
// adsense code
</if>
There might be something you could check so that you wouldn't need the plugin, but I couldn't see anything that was immediately obvious.
Reply With Quote
  #5  
Old 05-07-2014, 06:27 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Or in the template you could simply use this if condition
HTML Code:
<if condition="$show['search_engine']">
Reply With Quote
Благодарность от:
Lynne
  #6  
Old 05-07-2014, 02:15 PM
chefy chefy is offline
 
Join Date: Jul 2012
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You might be able to create a plugin using hook error_nopermission and code like:
Code:
$show['hide_adsense'] = true;
then in the template surround your adsense code with:
Code:
<if condition="!$show['hide_adsense']">
// adsense code
</if>
There might be something you could check so that you wouldn't need the plugin, but I couldn't see anything that was immediately obvious.
Unfortunately it's not working. When using your conditional I can still see the contents at every page even on those no permissions pages. Removing the ! prevents the content from being displayed at all pages without distinguishing no permission pages and yep I have double checked that I'm using the error_nopermission hook.

Quote:
Originally Posted by Simon Lloyd View Post
Or in the template you could simply use this if condition
HTML Code:
<if condition="$show['search_engine']">
Unfortunately this is also not working. It shows nothing at any page and when using the same conditional but preceded with a ! it shows the contents in all pages regardless if those are no permission pages.

I'm trying to do this in the navbar template, vBulletin 3.8.5
Reply With Quote
  #7  
Old 05-07-2014, 07:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, maybe you need to add a global statement, like:
Code:
global $show;
$show['hide_adsense'] = true;
Reply With Quote
Благодарность от:
Lynne
  #8  
Old 05-08-2014, 05:26 AM
chefy chefy is offline
 
Join Date: Jul 2012
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works, thank you very much man - you rock!
Reply With Quote
  #9  
Old 05-08-2014, 04:49 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by chefy View Post
Unfortunately this is also not working. It shows nothing at any page and when using the same conditional but preceded with a ! it shows the contents in all pages regardless if those are no permission pages.

I'm trying to do this in the navbar template, vBulletin 3.8.5
That shows it is working, preceeding it with ! means IF visitor (of any kind) is NOT a search engine then show everything inside the conditional, however if you were a search engine it will NOT show to you.
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 10:13 AM.


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.04385 seconds
  • Memory Usage 2,258KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (2)bbcode_html
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (3)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete