Different Template for login and register pages. Possible? Different Template for login and register pages. Possible?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Different Template for login and register pages. Possible?

Started by ChaosCrusader, May 26, 2005, 07:35:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ChaosCrusader

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

kegobeer

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?
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

ChaosCrusader

The code is a Javascript:

<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>

Nibbler

In your theme's theme.php, find the pageheader function and replace it with these 2 functions

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.

ChaosCrusader

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?

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;
}




kegobeer

Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

ChaosCrusader

Ok.  Thanks again.  Excellent support for an excellent product!