One of my sites uses a CMS based on system and I know nothing about PHP. In order to display ads I needed to add the following: function pageheader($section, $meta = '') { global $CONFIG, $THEME_DIR; global $template_header, $lang_charset, $lang_text_dir; header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"'); user_save_profile(); if ($CONFIG['language_list'] or $CONFIG['language_flags'] or $CONFIG['theme_list']) { $encoding = 'normal'; } else { $encoding = 'none'; } $template_vars = array('{LANG_DIR}' => $lang_text_dir, '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section, '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'], '{META}' => $meta, '{GAL_NAME}' => $CONFIG['gallery_name'], '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'], '{MAIN_MENU1}' => theme_main_menu1(), '{MAIN_MENU2}' => theme_main_menu2(), '{ADMIN_MENU}' => theme_admin_mode_menu(), '{ENCODING}' => $encoding, '{AD}' => generate_ad_block(), '{BOTTOM}' => generate_bottom() ); 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 = "xxx"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel ="xxx"; 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_bottom() { if (!defined('REGISTER_PHP') && !defined('LOGIN_PHP')){ $bottom = <<< EOT <center><script type="text/javascript"><!-- google_ad_client = "xxx"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel ="xxx"; 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 $bottom = ''; return $bottom; } PHP: And then in the template.html file you just put {AD} where you want to display the ad. That works perfectly. My problem is that I now want to add a second ad unit. I modified the code with the {BOTTOM} function as above. But it seems that it doesn't get parsed (that the right word?), because when I view the page, the top ad unite {AD} shows normally, but the bottom one only displays {BOTTOM} The reason for this code is to not display ads on the register and login pages as per Google's TOS. Anyone that can help? The second unit should be displayed at the bottom of the page. Could that be the problem as I think the code above has something to do with pageheader?
Alternatively, and I don't know if this will work. Can I add a php include on the template file and then use that to detect what the page is an act accordingly. Something like: if page=!register.php & page=!login.php then include ads.inc otherwise do nothing I've got no idea how to write this in PHP or even if that would work.
Crusader The PHP you show seems fine. THe {AD} syntax however is not PHP. It is provided by the template system your using. The function call to template_eval(...) on line 29 is where the problem seems to be. It is not recognising the {BOTTOM} tag. If you can look at the code in that function and duplicate what it does when it sees the {AD} tag.
If you have the same code for ad generation for the {AD} block and the {BOTTOM} block then why have 'BOTTOM' => generate_bottom() ? try changing generate_bottom() to generate_ad_block() that will fix it. if not paste here the template file also.