SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist Crusader's Avatar
    Join Date
    Oct 2004
    Location
    South Africa
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How NOT to display ads on certain pages

    I'm using Coppermine Photo Gallery for my website, and I've added Google Adsense Code to my template used for the gallery. It works fine, but the problem is that the ads are now shown on the login.php and register.php pages, which is against Google's ToS.

    I don't know much about PHP or Javascript. Would there be a way I could change the template to not include those two pages?

  2. #2
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something along those lines

    PHP Code:
    if ( $_SERVER['PHP_SELF'] != "register.php" && $_SERVER['PHP_SELF'] != "login.php" ) {
      
    // display ads

    Last edited by ClickHeRe; May 25, 2005 at 14:19.

  3. #3
    SitePoint Evangelist Crusader's Avatar
    Join Date
    Oct 2004
    Location
    South Africa
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I ad that to a normal HTML file? I don't know much about PHP (read nothing!)

  4. #4
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in that case you will use the code like

    PHP Code:

    HTML code before

    <?php
    if ( $_SERVER['PHP_SELF'] != "register.php" && $_SERVER['PHP_SELF'] != "login.php" ) {
    ?>
      HTML ad code here
    <?php
    }
    ?>

    HTML code after
    Last edited by ClickHeRe; May 25, 2005 at 14:20.

  5. #5
    SitePoint Evangelist Crusader's Avatar
    Join Date
    Oct 2004
    Location
    South Africa
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've Added the fllowing to the template html, but the ads still show up.
    I must be doing something wrong.
    Code:
    <?php
    if ( $_SERVER['PHP_SELF'] != "register.php" || $_SERVER['PHP_SELF'] != "login.php" ) {
    ?>
    <!--AD CODE-->
    <center><br>              
                <script type="text/javascript"><!--
    google_ad_client = "xxxxx";
    google_ad_width = 468;
    google_ad_height = 60;
    google_ad_format = "468x60_as";
    google_ad_type = "text";
    google_page_url = document.location;
    google_color_border = "5B5B5B";
    google_color_bg = "5B5B5B";
    google_color_link = "FFFFFF";
    google_color_url = "FFFFFF";
    google_color_text = "FFFFFF";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></center>
    <!--End AdCODE-->
    <?php
    }
    ?>

  6. #6
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should be ok (I hope so =])

    PHP Code:
    <?php
    if ( basename$_SERVER['PHP_SELF'] ) != "register.php" && basename$_SERVER['PHP_SELF'] ) != "login.php" ) {
    ?>
    <!--AD CODE-->
    <center><br>              
                <script type="text/javascript"><!--
    google_ad_client = "xxxxx";
    google_ad_width = 468;
    google_ad_height = 60;
    google_ad_format = "468x60_as";
    google_ad_type = "text";
    google_page_url = document.location;
    google_color_border = "5B5B5B";
    google_color_bg = "5B5B5B";
    google_color_link = "FFFFFF";
    google_color_url = "FFFFFF";
    google_color_text = "FFFFFF";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></center>
    <!--End AdCODE-->
    <?php
    }
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •