// Banners Ads - Fully configurable from ACP - v1.0 - First release
Responding for this topic :
http://www.4homepages.de/forum/index.php?topic=11035.0Since most of E-Commerce scripts uses this type of functionnality, I never realized the importance of this feature before today.
// Affected files- admin/settings.php.
- lang/<your_lang>/admin.php (assuming english).
- includes/page_header.php
- SETTINGS_TABLE.
// PurposeAs we all know already, this feature allows you to show your ads banner from, either, the top header and / or your footer below your site (depending of the configuration you chosed from your ACP's settings).
// Step 1In your admin/settings.php file,
find :
function show_setting_row($setting_name, $value_option = "", $htmlspecialchars = 0) {
global $config, $setting;
$config_value = ($htmlspecialchars) ? htmlspecialchars($config[$setting_name]) : $config[$setting_name];
$setting[$setting_name] = replace_url($setting[$setting_name]);
if ($value_option == "") {
show_input_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value);
}
elseif ($value_option == "textarea") {
show_textarea_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value, "", 6);
}
elseif ($value_option == "radio") {
show_radio_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value);
}
else {
echo "<tr class=\"".get_row_bg()."\">\n<td valign=\"top\"><p class=\"rowtitle\">".$setting[$setting_name]."</p></td>\n";
echo "<td><p>";
$value_option($setting_name, $config_value);
echo "</p></td>\n</tr>\n";
}
}
add below :
function show_ads_banner_header_options($setting_name, $setting_value) {
global $set_ads_banner_header_optionlist;
echo "<select name=\"setting_item[".$setting_name."]\">";
foreach ($set_ads_banner_header_optionlist as $key => $val) {
echo "<option value=\"$key\"";
if ($setting_value == $key) {
echo " selected=\"selected\"";
}
echo ">".$val."</option>";
}
echo "</select>";
}
function show_ads_banner_footer_options($setting_name, $setting_value) {
global $set_ads_banner_footer_optionlist;
echo "<select name=\"setting_item[".$setting_name."]\">";
foreach ($set_ads_banner_footer_optionlist as $key => $val) {
echo "<option value=\"$key\"";
if ($setting_value == $key) {
echo " selected=\"selected\"";
}
echo ">".$val."</option>";
}
echo "</select>";
}
Then, find :
show_table_separator($setting_group[3], 2, "#setting_group_3");
show_setting_row("image_order", "show_image_order_select");
show_setting_row("image_sort", "show_image_sort_select");
show_setting_row("new_cutoff");
show_setting_row("image_border");
show_setting_row("image_cells");
show_setting_row("default_image_rows");
show_setting_row("custom_row_steps");
show_setting_row("image_table_width");
show_setting_row("image_table_cellspacing");
show_setting_row("image_table_cellpadding");
add below :
show_table_separator($setting_group[X], 2, "#setting_group_X");
show_setting_row("ads_banner_header", "show_ads_banner_header_options");
show_setting_row("ads_banner_footer", "show_ads_banner_footer_options");
show_setting_row("ads_banner_url");
Note : You must change the "X" letter to your next new number.
Example : Assuming you have the first 10 values already, simply add 11 on this one.
// Step 2In your lang/english/admin.php file, above the "?>" tag,
add this :
/*-- Setting-Group X --*/
$setting_group[X] = "Banner Ads Activation Options";
$set_ads_banner_header_optionlist = array(
"1" => "yes",
"2" => "no",
);
$setting['ads_banner_header'] = "<span class=\"smalltext\">Would you like to activate your Banners Ads on your album's site header page (top) ?</span>";
$set_ads_banner_footer_optionlist = array(
"1" => "yes",
"2" => "no",
);
$setting['ads_banner_footer'] = "<span class=\"smalltext\">Would you like to activate your Banners Ads on your album's site footer page (below) ?</span>";
$setting['ads_banner_url'] = "<span class=\"smalltext\">If you chosed to activate (at least) one of these two above, please specify the URL where the clicker should be redirected.";
(Remember the 'X' rules above).
// Step 3In your includes/page_header.php file,
find :
// Cache Templates
$template_list = 'header,footer,category_dropdown_form,user_logininfo,user_loginform';
if (isset($templates_used) && $templates_used != "") {
$template_list = $template_list.",".$templates_used;
}
$site_template->cache_templates($template_list);
add below :
//-----------------------------------------------------
//--- Ads Banner --------------------------------------
//-----------------------------------------------------
if ($config['ads_banner_header'] != 2) {
$site_template->register_vars(array(
"banner_header_url" => ($config['ads_banner_url'] != "") ? "<br />".$config['ads_banner_url']."<br /><br />" : ""
));
} ###### End of if statement.
if ($config['ads_banner_footer'] != 2) {
$site_template->register_vars(array(
"banner_footer_url" => ($config['ads_banner_url'] != "") ? "<br /><br />".$config['ads_banner_url']."<br /><br />" : ""
));
} ###### End of if statement.
// Step 4Then, add the following SQL fields in your SETTINGS_TABLE :
- Setting_name: ads_banner_header
- Setting_value: 1
- Setting_name: ads_banner_footer
- Setting_value: 1
- Setting_name: ads_banner_url
- Setting_value: your_url
// Step 5In your templates/<your_template>/header.html file, you can fully customize the way you'd like to show it.
However, just use these tags to show your header banner ads correctly :
{if banner_header_url}
{banner_header_url}
{endif banner_header_url}
// Step 6In your templates/<your_template>/footer.html file, you can also customize your presentation in the way you'd like.
However, use these codes to show your footer banner correctly :
{if banner_footer_url}
{banner_footer_url}
{endif banner_footer_url}
// Installation CompleteThis completes the installation of this MOD.
// Try-outTo test it out, go to your ACP's configuration page and activate, either (or both) banners in order to show it from your header / footer - depending on your personal preference. Then, right below these two choices, simply add the given URL from your affiliate and the banner show be able to appear genericly from your album once you'll save your settings.
Enjoy and, hopefully, someone will send HIS INPUTS THIS TIME !!!
// Banners Ads - Fully configurable from ACP - v2.0 - Full installation
// ChangelogThis topic was updated on : [ 01/26/2006 ].
---
This topic was updated on : [ 01/27/2006 ].
A new folder called :
banner is now involved in the new version.
A single general function is being used rather than two seperated functions from the settings page (since it is useless) and uses less SQL ressources.
// Affected filesSame as v1.0 above (
except includes/functions.php file in addition).
// PurposeSame purpose as above - except this time - images for your header and footer are fully configurable from your ACP's configuration page and, both, are seperated options according to your decision - if you wish to activate them or not.
Note: For users who has never installed this MOD before, there's no need to install v1.0 before the v2.0. You can install this version right away. For users who did installed the v1.0 before, it would be HIGHLY recommended you uninstall this MOD and install the new version instead. Much more and better functionnality has been established now.// Step 1In your admin/settings.php file,
find :
function show_setting_row($setting_name, $value_option = "", $htmlspecialchars = 0) {
global $config, $setting;
$config_value = ($htmlspecialchars) ? htmlspecialchars($config[$setting_name]) : $config[$setting_name];
$setting[$setting_name] = replace_url($setting[$setting_name]);
if ($value_option == "") {
show_input_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value);
}
elseif ($value_option == "textarea") {
show_textarea_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value, "", 6);
}
elseif ($value_option == "radio") {
show_radio_row($setting[$setting_name], "setting_item[".$setting_name."]", $config_value);
}
else {
echo "<tr class=\"".get_row_bg()."\">\n<td valign=\"top\"><p class=\"rowtitle\">".$setting[$setting_name]."</p></td>\n";
echo "<td><p>";
$value_option($setting_name, $config_value);
echo "</p></td>\n</tr>\n";
}
}
add below :
function show_ads_banner_header_footer_options($setting_name, $setting_value) {
global $set_ads_banner_header_footer_optionlist;
echo "<select name=\"setting_item[".$setting_name."]\">";
foreach ($set_ads_banner_header_footer_optionlist as $key => $val) {
echo "<option value=\"$key\"";
if ($setting_value == $key) {
echo " selected=\"selected\"";
}
echo ">".$val."</option>";
}
echo "</select>";
}
function show_banner_dir_select($setting_name, $setting_value) {
echo "<select name=\"setting_item[".$setting_name."]\">";
$handle = @opendir(TEMPLATE_PATH."/images/banner");
$folderlist[] = "---\n";
while (false !== ($file = @readdir($handle))) {
if (@is_dir(TEMPLATE_PATH."/images/banner") && $file != "." && $file != "..") {
$folderlist[] .= $file;
}
}
@sort($folderlist);
for($i = 0; $i < sizeof($folderlist); $i++) {
echo "<option value=\"".$folderlist[$i]."\"";
if ($setting_value == $folderlist[$i]) {
echo " selected=\"selected\"";
}
echo ">".$folderlist[$i]."</option>\n";
}
@closedir($handle);
echo "</select>\n";
}
Then, find :
show_table_separator($setting_group[3], 2, "#setting_group_3");
show_setting_row("image_order", "show_image_order_select");
show_setting_row("image_sort", "show_image_sort_select");
show_setting_row("new_cutoff");
show_setting_row("image_border");
show_setting_row("image_cells");
show_setting_row("default_image_rows");
show_setting_row("custom_row_steps");
show_setting_row("image_table_width");
show_setting_row("image_table_cellspacing");
show_setting_row("image_table_cellpadding");
add below :
show_table_separator($setting_group[X], 2, "#setting_group_X");
show_setting_row("ads_banner_header", "show_ads_banner_header_footer_options");
show_setting_row("ads_banner_footer", "show_ads_banner_header_footer_options");
show_setting_row("ads_banner_header_image_url", "show_banner_dir_select");
show_setting_row("ads_banner_footer_image_url", "show_banner_dir_select");
show_setting_row("ads_banner_header_url");
show_setting_row("ads_banner_footer_url");
Note: Replace the 'X" with the latest value of the setting group.
// Step 2In your lang/english/admin.php file,
add before your '?>' tag (
code updated below - thanks to JensF for pointing the array error.):
/*-- Setting-Group xx --*/
$setting_group[xx] = "Banner Ads Activation Options";
$set_ads_banner_header_header_optionlist = array(
"1" => "yes",
"2" => "no",
);
$setting['ads_banner_header'] = "<span class=\"smalltext\">Would you like to activate your Banners Ads on your album's site header page (top) ?</span>";
$set_ads_banner_header_footer_optionlist = array(
"1" => "yes",
"2" => "no",
);
$setting['ads_banner_footer'] = "<span class=\"smalltext\">Would you like to activate your Banners Ads on your album's site footer page (below) ?</span>";
$setting['ads_banner_header_image_url'] = "<span class=\"smalltext\">Please select your banner ads image you would like to show from your site header.";
$setting['ads_banner_header_url'] = "<span class=\"smalltext\">If you chosed to activate the banner from the site header, please specify the URL (which will go with your selected image).";
$setting['ads_banner_footer_image_url'] = "<span class=\"smalltext\">Please select your banner ads image you would like to show from your site footer.";
$setting['ads_banner_footer_url'] = "<span class=\"smalltext\">If you chosed to activate the banner from the site footer, please specify the URL (which will go with your selected image).";
Remember the 'X' rule.
// Step 3In your includes/page_header.php file,
find :
// Cache Templates
$template_list = 'header,footer,category_dropdown_form,user_logininfo,user_loginform';
if (isset($templates_used) && $templates_used != "") {
$template_list = $template_list.",".$templates_used;
}
$site_template->cache_templates($template_list);
add below :
//-----------------------------------------------------
//--- Ads Banner --------------------------------------
//-----------------------------------------------------
if ($config['ads_banner_header'] == 1) {
$site_template->register_vars(array(
"banner_header_url" => (@file_exists(TEMPLATE_PATH."/images/banner/".$config['ads_banner_header_image_url']) && $config['ads_banner_header_url'] != "") ? "<br /><center><a href=\"".$config['ads_banner_header_url']."\"><img src=\"".get_banner_image($config["ads_banner_header_image_url"])."\" border=\"0\" target=\"_blank\"></a></center><br /><br />" : ""
));
} ###### End of if statement.
if ($config['ads_banner_footer'] == 1) {
$site_template->register_vars(array(
"banner_footer_url" => (@file_exists(TEMPLATE_PATH."/images/banner/".$config['ads_banner_footer_image_url']) && $config['ads_banner_footer_url'] != "") ? "<br /><br /><center><a href=\"".$config["ads_banner_footer_url"]."\"><img src=\"".get_banner_image($config["ads_banner_footer_image_url"])."\" border=\"0\" target=\"_blank\"></a></center><br /><br />" : ""
));
} ###### End of if statement.
// Step 4In your includes/functions.php file,
find :
function get_gallery_image($image_name) {
global $config;
if (file_exists(TEMPLATE_PATH."/images_".$config['language_dir']."/".$image_name)) {
return TEMPLATE_PATH."/images_".$config['language_dir']."/".$image_name;
}
else {
return TEMPLATE_PATH."/images/".$image_name;
}
}
add below :
function get_banner_image($banner_name) {
if (@file_exists(TEMPLATE_PATH."/images/banner/".$banner_name)) {
return TEMPLATE_PATH."/images/banner/".$banner_name;
}
}
// Step 5 (Updated on: 02/12/2006)Create a file called :
install_ads.php on your ROOT_PATH folder (remember, this is a FRESH install !) and
add the following setting name in your SETTINGS_TABLE :
<?php
define ('ROOT_PATH', './');
include (ROOT_PATH."global.php");
require (ROOT_PATH."includes/sessions.php");
$user_access = get_permission();
if ($user_info['user_level'] == ADMIN) {
$sql = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_header', '2')
";
$result = $site_db->query($sql);
$sql1 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_footer', '2')
";
$result1 = $site_db->query($sql1);
$sql2 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_header', '2')
";
$result2 = $site_db->query($sql2);
$sql3 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_header_image_url', '')
";
$result3 = $site_db->query($sql3);
$sql4 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_footer_image_url', '')
";
$result4 = $site_db->query($sql4);
$sql5 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_header_url', '')
";
$result5 = $site_db->query($sql5);
$sql6 = "INSERT INTO ".SETTINGS_TABLE."
(setting_name, setting_value)
VALUES ('ads_banner_footer_url', '')
";
$result6 = $site_db->query($sql6);
if ($result && $result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
echo "Installation successful.";
} else {
echo "Installation failed.";
} ####### End of if statement.
} ####### End of if statement.
?>
// Step 6In your templates/<your_template>/header.html file,
add the following below your <BODY> tag :
{if banner_header_url}{banner_header_url}{endif banner_header_url}
// Step 7In your templates/<your_template>/footer.html file,
find :
{cp_link}
add below :
{if banner_footer_url}{banner_footer_url}{endif banner_footer_url}
// Step 8[Updated since 01-27-2006]In your templates/<your_template>/images folder, create a new folder called :
banner.
// Installation completeThis completes the installation of this MOD.
// Try-outTo test it out, go to your ACP's configuration page and activate, either (or both) banners in order to show it from your header / footer - depending on your personal preference. Then, right below these two choices, simply choose your images for your header + footer and add the given URL (for each - if required) from your affiliate and the banner show be able to appear genericly from your album once you'll save your settings.
// Where are the upgrade instructions ?If there's enough place on this topic to type it all, I'll post these instructions.
Good luck !