forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: ChaosCrusader on May 26, 2005, 07:35:57 pm

Title: Different Template for login and register pages. Possible?
Post by: ChaosCrusader on May 26, 2005, 07:35:57 pm
Hi guys.  I'm currently using Adsense to generate revenue on a Coppermine based site.  The problem is that the adsense code is added in the template.html file, and thus shows up on all the pages including the register and login pages, which isn't allowed by Google.  Is there a way to perhaps use a different template for those files only or in some way remove the adsense code/stop it from showing on the login.php and register.php files?

I have no knowledge of PHP or Javascript so any help would be MUCH appreciated.  I'm totally clueless on how to accomplish this.   ???

PS.  Using Coppermine 1.3.3
Title: Re: Different Template for login and register pages. Possible?
Post by: kegobeer on May 27, 2005, 05:20:17 am
If the code is just a long string, it wouldn't have to go in your template file.  It could easily be parsed in the theme.php file and dropped into a token (like the {GALLERY} token in template.html) only if login.php and register.php aren't calling the template.

What's the code?
Title: Re: Different Template for login and register pages. Possible?
Post by: ChaosCrusader on May 27, 2005, 06:30:49 am
The code is a Javascript:

Code: [Select]
<center><br>             
            <script type="text/javascript"><!--
google_ad_client = "xxxxx";
google_alternate_ad_url = "xxxxl";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel ="";
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>
Title: Re: Different Template for login and register pages. Possible?
Post by: Nibbler on May 27, 2005, 06:48:01 pm
In your theme's theme.php, find the pageheader function and replace it with these 2 functions

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
'{AD}' => generate_ad_block()
        );

    echo template_eval($template_header, $template_vars);
}

function generate_ad_block()
{
if (!defined('REGISTER_PHP') && !defined('LOGIN_PHP')){
$ad = <<< EOT

<center><br>             
            <script type="text/javascript"><!--
google_ad_client = "xxxxx";
google_alternate_ad_url = "xxxxl";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel ="";
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>
EOT;

} else $ad = '';

return $ad;
}

than add {AD} into your template.html where you want the ad to appear.
Title: Re: Different Template for login and register pages. Possible?
Post by: ChaosCrusader on May 27, 2005, 07:40:34 pm
Thanks a million!  That did the trick perfectly.  Just a question, if I want to do the same for another ad, can I just modify the code as follows for the second ad?

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
'{AD}' => generate_ad_block(),
'{AD2}' => generate_ad_block2()
        );

    echo template_eval($template_header, $template_vars);
}

function generate_ad_block()
{
if (!defined('REGISTER_PHP') && !defined('LOGIN_PHP')){
$ad = <<< EOT

<center><br>             
            <script type="text/javascript"><!--
google_ad_client = "xxxxx";
google_alternate_ad_url = "xxxxl";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel ="";
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>
EOT;

} else $ad = '';

return $ad;
}

function generate_ad_block2()
{
if (!defined('REGISTER_PHP') && !defined('LOGIN_PHP')){
$ad = <<< EOT

<center><br>             
            <script type="text/javascript"><!--
code_ for_other_ad;
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>
EOT;

} else $ad = '';

return $ad;
}



Title: Re: Different Template for login and register pages. Possible?
Post by: kegobeer on May 27, 2005, 07:43:31 pm
Yes.
Title: Re: Different Template for login and register pages. Possible?
Post by: ChaosCrusader on May 28, 2005, 02:12:35 pm
Ok.  Thanks again.  Excellent support for an excellent product!