![]() |
|
|
#1
|
||||
|
||||
|
Removing Adsense Code on certain pages
My Javascript knowledge is next to none. One of my sites uses a template to function, and I can only include the Adsense code in this template file. The problem is that causes the adsense ads to be displayed on all pages including the login.php and register.php files, which is against Google ToS, which I don't want to break.
I'm looking for a way to exclude a section of HTML code, if the filename is login.php or register.php. Is there some way this can be done using Javascript? Last edited by Crusader; May 25th 2005 at 12:52 pm. |
|
#2
|
||||
|
||||
|
The only way I have managed this was using nested templates, and removing the adsense - an easier way would be good!!
|
|
#3
|
|||
|
|||
|
If the files are PHP - as the extension suggests - at the top of your register.php and login.php, put something like this:-
$noadsense = 1; Then, replace your adsense code with this:- <? if ($noadsense <> 1) { ?> //PUT YOUR ADSENSE CODE HERE <? } ?> On any page you don't want adsense ads to show, just pop that first piece of code in. Not javascript, but hey...
|
|
#4
|
||||
|
||||
|
The template file is a HTML file so I don't know if this will still work?
|
|
#5
|
|||
|
|||
|
It depends on how your CMS uses the template files. If it just outputs them as HTML and your pages are parsed by php, then it will work.
|
|
#6
|
|||
|
|||
|
Ok, then no need for php
Search in go a little bit, and using the idea above try to do it using
document.write or innerHtml... (just a tip, no it's your time) |
|
#7
|
||||
|
||||
|
The PHP solution seems to be the best option, but it doesn't work correctly for me. I've added it to the template.html file. When I view the page after it's parsed I get
1) { ?> Followed by the adsense ad. This is on a page where the ad is supposed to show. |
|
#8
|
||||
|
||||
|
Perfect, thanks a lot!!!
|
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
||||
|
||||
|
It's the site in my sig. The gallery part at least.
|
|
#11
|
||||
|
||||
|
Ok, I got this working with a test page. But after using it in the HTML file, it doesn't seem as if the values from the noadsense variable gets detected from the login.php & register.php files.
I've added the $noadsense = 1; at the top of the login.php file php Code:
|
|
#12
|
||||
|
||||
|
Arghh.. nothing seems to work. I need help. Perhaps Javascript would be the better option, but I can't seem to be able to make head or tails on how to go about it.
|
|
#13
|
||||
|
||||
|
You should only put the values in .php files.
if the section where your adsense gets included is in a function, you can try to put $global noadsense; just after the function decleration.
__________________
Add Your Article Directory **Webmasters: Earn up to $52 per sale, Lifetime Commissions! |
|
#14
|
||||
|
||||
|
I've added the $global noadsense; ,but it doesn't make any difference.
|
|
#15
|
||||
|
||||
|
sorry that should be global $noadsense
..
__________________
Add Your Article Directory **Webmasters: Earn up to $52 per sale, Lifetime Commissions! |
|
#16
|
||||
|
||||
|
mm when I look at the source, i see
<?php global $noadsense; print "noadsense"; if ($noadsense != 1) { ?> that means the php didnt get parsed. (iow you put the code in the template file, and it just got included that way) is the code you posted above the login.php file?
__________________
Add Your Article Directory **Webmasters: Earn up to $52 per sale, Lifetime Commissions! |
|
#17
|
||||
|
||||
|
Yes the code above is part of the login.php file.
I also now noticed that it didn't get parsed. Why would that be? I've included the following in my htaccess file " addtype application/x-httpd-php .php .shtml .htm .html" shouldn't that solve the parsing problem? |
|
#18
|
||||
|
||||
|
Ok, I think I got a solution.
edit the template.html file, remove all the adsense code and instead put only {ADSENSE} then edit include/functions.inc.php, and go to the load_template() function add php Code:
php Code:
__________________
Add Your Article Directory **Webmasters: Earn up to $52 per sale, Lifetime Commissions! |
|
#19
|
||||
|
||||
|
Thanks for all the help. I contacted the guys that wrote Coppermine and they gave me an excellent fix, that works perfectly!
|
|
#20
|
||||
|
||||
|
Care to share that fix with us?
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adsense in member's logged in pages. | TommyD | Guidelines / Compliance | 0 | Apr 25th 2005 8:29 am |
| Can you use the Adsense search code forr froogle and local search? | crazyhorse | AdSense | 2 | Apr 16th 2005 5:47 am |
| Is this possible to edit Adsense ads code | pentium9 | Guidelines / Compliance | 5 | Apr 14th 2005 8:50 pm |
| getting better rankings for deeper pages | fluke | Search Engine Optimization | 42 | Aug 23rd 2004 11:27 pm |