Digital Point Forums
Money Order

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old May 25th 2005, 12:39 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
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?
__________________
Free Space wallpapers | Digital Photography | |

Last edited by Crusader; May 25th 2005 at 12:52 pm.
Reply With Quote
  #2  
Old May 25th 2005, 12:44 pm
Jim bob 9 pants's Avatar
Jim bob 9 pants Jim bob 9 pants is offline
Twilight Vanquisher
 
Join Date: Jan 2005
Location: Helston, Cornwall, UK
Posts: 883
Jim bob 9 pants is on a distinguished road
The only way I have managed this was using nested templates, and removing the adsense - an easier way would be good!!
Reply With Quote
  #3  
Old May 25th 2005, 12:56 pm
KMxRetro KMxRetro is offline
Peon
 
Join Date: May 2005
Posts: 22
KMxRetro is on a distinguished road
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...
Reply With Quote
  #4  
Old May 25th 2005, 1:03 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
The template file is a HTML file so I don't know if this will still work?
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #5  
Old May 25th 2005, 1:16 pm
exam exam is offline
of the Nightfall
 
Join Date: Sep 2004
Location: In front of the monitor
Posts: 2,407
exam is just really niceexam is just really niceexam is just really niceexam is just really niceexam is just really nice
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.
__________________
Submit your siteSubmit your article
Reply With Quote
  #6  
Old May 25th 2005, 1:23 pm
tresman tresman is offline
Champion of the Naaru
 
Join Date: Dec 2004
Posts: 235
tresman will become famous soon enough
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)
Reply With Quote
  #7  
Old May 25th 2005, 1:32 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
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.
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #8  
Old May 25th 2005, 1:41 pm
Jim bob 9 pants's Avatar
Jim bob 9 pants Jim bob 9 pants is offline
Twilight Vanquisher
 
Join Date: Jan 2005
Location: Helston, Cornwall, UK
Posts: 883
Jim bob 9 pants is on a distinguished road
Perfect, thanks a lot!!!
Reply With Quote
  #9  
Old May 25th 2005, 1:46 pm
exam exam is offline
of the Nightfall
 
Join Date: Sep 2004
Location: In front of the monitor
Posts: 2,407
exam is just really niceexam is just really niceexam is just really niceexam is just really niceexam is just really nice
Quote:
Originally Posted by Crusader
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.
For it to work, *all* pages have to be parsed by php. Care to post your site?
__________________
Submit your siteSubmit your article
Reply With Quote
  #10  
Old May 25th 2005, 2:01 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
It's the site in my sig. The gallery part at least.
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #11  
Old May 25th 2005, 3:14 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
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:
$noadsense = 1;


/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.3.3
  $Source: /cvsroot/coppermine/stable/register.php,v $
  $Revision: 1.11 $
  $Author: gaugau $
  $Date: 2005/04/19 03:17:11 $
**********************************************/


define('IN_COPPERMINE', true);
define('REGISTER_PHP', true);

require('include/init.inc.php');
require('include/mailer.inc.php');

if (!$CONFIG['allow_user_registration'] || USER_ID) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);

if (defined('UDB_INTEGRATION')) udb_register_page();
// Display the disclaimer
function display_disclaimer()
{
    global $CONFIG, $PHP_SELF;
    global $lang_register_disclamer, $lang_register_php;

    starttable(-1, $lang_register_php['term_cond']);
    echo <<<EOT
        <form method="post" action="$PHP_SELF">
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #12  
Old May 25th 2005, 3:33 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
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.
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #13  
Old May 25th 2005, 3:58 pm
Dejavu's Avatar
Dejavu Dejavu is offline
Twilight Vanquisher
 
Join Date: Apr 2005
Posts: 916
Dejavu has a spectacular aura aboutDejavu has a spectacular aura about
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.
Reply With Quote
  #14  
Old May 25th 2005, 4:08 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
I've added the $global noadsense; ,but it doesn't make any difference.
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #15  
Old May 25th 2005, 4:11 pm
Dejavu's Avatar
Dejavu Dejavu is offline
Twilight Vanquisher
 
Join Date: Apr 2005
Posts: 916
Dejavu has a spectacular aura aboutDejavu has a spectacular aura about
sorry that should be global $noadsense
..
Reply With Quote
  #16  
Old May 25th 2005, 4:16 pm
Dejavu's Avatar
Dejavu Dejavu is offline
Twilight Vanquisher
 
Join Date: Apr 2005
Posts: 916
Dejavu has a spectacular aura aboutDejavu has a spectacular aura about
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?
Reply With Quote
  #17  
Old May 25th 2005, 4:24 pm
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
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?
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #18  
Old May 25th 2005, 4:44 pm
Dejavu's Avatar
Dejavu Dejavu is offline
Twilight Vanquisher
 
Join Date: Apr 2005
Posts: 916
Dejavu has a spectacular aura aboutDejavu has a spectacular aura about
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:
global $noadsense;
at top, and put these lines at end
php Code:
if ($noadsense <> 1){
$adsense = '<your adsense code.
..'
;
}
else{
$adsense = '';
}
$template = str_replace('{ADSENSE}', $adsense ,$template);
Reply With Quote
  #19  
Old May 27th 2005, 10:41 am
Crusader's Avatar
Crusader Crusader is offline
of the Nightfall
 
Join Date: Apr 2005
Location: South Africa
Posts: 1,732
Crusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the roughCrusader is a jewel in the rough
Thanks for all the help. I contacted the guys that wrote Coppermine and they gave me an excellent fix, that works perfectly!
__________________
Free Space wallpapers | Digital Photography | |
Reply With Quote
  #20  
Old Aug 5th 2006, 9:37 pm
cyanyde's Avatar
cyanyde cyanyde is offline
Champion of the Naaru
 
Join Date: Jun 2006
Posts: 131
cyanyde is on a distinguished road
Care to share that fix with us?
Reply With Quote
Reply

Bookmarks

Thread Tools

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


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


All times are GMT -8. The time now is 3:42 am.