defender39 Posted November 24, 2003 Posted November 24, 2003 I have just completed a better version of the affiliate_banners_build.php where there is a drop down menu for the product listings...I basically ripped some code from the admin side that was in specials where all the products get pulled. This function could also be used maybe for a quick cart add on mod which I just though of while typing this... I will look into that. Basically before when affiliates wanted to create a link to a direct product they had to find the product id themselves and enter it....now they can just use the pulldown menu complete with price. I can zip this up and add it to the contrib section too if you feel thats a good idea. <?php /* $Id: affiliate_banners_build.php,v 1.0 2003/04/29 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); if (!tep_session_is_registered('affiliate_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_AFFILIATE, '', 'SSL')); } require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_AFFILIATE_BANNERS); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_AFFILIATE_BANNERS)); $affiliate_banners_values = tep_db_query("select * from " . TABLE_AFFILIATE_BANNERS . " order by affiliate_banners_title"); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <?php if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require(DIR_WS_INCLUDES . 'header_tags.php'); } else { ?> <title><?php echo TITLE ?></title> <?php } ?> <base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" height="28" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_specials.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> <tr> <td colspan=2 class="main"><?php echo TEXT_INFORMATION; ?></td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td class="infoBoxHeading" align="center"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER . ' ' . $affiliate_banners['affiliate_banners_title']; ?></td> </tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_INFO . tep_draw_form('individual_banner', tep_href_link(FILENAME_AFFILIATE_BANNERS_BUILD) ) . "\n" . tep_draw_products_pull_down('individual_banner_id', 'style="font-size:10px"') . tep_image_submit('button_affiliate_build_a_link.gif', IMAGE_BUTTON_BUILD_A_LINK); ?></form></td> </tr> <?php if (tep_not_null($HTTP_POST_VARS['individual_banner_id']) || tep_not_null($HTTP_GET_VARS['individual_banner_id'])) { if (tep_not_null($HTTP_POST_VARS['individual_banner_id'])) $individual_banner_id = $HTTP_POST_VARS['individual_banner_id']; if ($HTTP_GET_VARS['individual_banner_id']) $individual_banner_id = $HTTP_GET_VARS['individual_banner_id']; $affiliate_pbanners_values = tep_db_query("select p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $individual_banner_id . "' and pd.products_id = '" . $individual_banner_id . "' and p.products_status = '1' and pd.language_id = '" . $languages_id . "'"); if ($affiliate_pbanners = tep_db_fetch_array($affiliate_pbanners_values)) { switch (AFFILIATE_KIND_OF_BANNERS) { case 1: $link = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $individual_banner_id . '&affiliate_banner_id=1" target="_blank"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $affiliate_pbanners['affiliate_banners_image'] . '" border="0" alt="' . $affiliate_pbanners['products_name'] . '"></a>'; $link2 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $individual_banner_id . '&affiliate_banner_id=1" target="_blank">' . $affiliate_pbanners['products_name'] . '</a>'; break; case 2: // Link to Products $link = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $individual_banner_id . '&affiliate_banner_id=1" target="_blank"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_SHOW_BANNER . '?ref=' . $affiliate_id . '&affiliate_pbanner_id=' . $individual_banner_id . '" border="0" alt="' . $affiliate_pbanners['products_name'] . '"></a>'; $link2 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $individual_banner_id . '&affiliate_banner_id=1" target="_blank">' . $affiliate_pbanners['products_name'] . '</a>'; break; } } ?> <tr> <td class="smallText" align="center"><?php echo $link; ?></td> </tr> <tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INFO; ?></td> </tr> <tr> <td class="smallText" align="center"> <textarea cols="60" rows="6" class="boxText"><?php echo $link; ?></textarea> </td> </tr> <tr> <td> <td> </tr> <tr> <td class="smallText" align="center"><b>Text Version:</b> <?php echo $link2; ?></td> </tr> <tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INFO; ?></td> </tr> <tr> <td class="smallText" align="center"> <textarea cols="60" rows="6" class="boxText"><?php echo $link2; ?></textarea> </td> </tr> <tr> <td> <td> </tr> <?php } ?> </td> </tr> </table> </td> </tr> </table></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> and add these 2 functions to your application_top.php in /catalog/includes/ function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') { global $currencies, $languages_id; if ($exclude == '') { $exclude = array(); } $select_string = '<select name="' . $name . '"'; if ($parameters) { $select_string .= ' ' . $parameters; } $select_string .= '>'; $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by products_name"); while ($products = tep_db_fetch_array($products_query)) { if (!tep_in_array($products['products_id'], $exclude)) { $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>'; } } $select_string .= '</select>'; return $select_string; } function tep_in_array($lookup_value, $lookup_array) { if (function_exists('in_array')) { if (in_array($lookup_value, $lookup_array)) return true; } else { reset($lookup_array); while (list($key, $value) = each($lookup_array)) { if ($value == $lookup_value) return true; } } Quote
dkap Posted November 24, 2003 Posted November 24, 2003 Seems like a good idea. The popup approach is a bit clunky for the intended purpose, although it could probably be smoothed out with an auto-closing window that fills in the product selection. Still, your approach sounds plenty simple and streamlined. Dan Quote
Guest Posted January 24, 2005 Posted January 24, 2005 Made a few fixes to the affiliate_banners_build.php file. Now the banner links actually work and the UI is a bit more consistent. This file includes the product dropdown modification from "defender39 Posted Nov 24 2003, 12:00 AM" so you will need his two new functions. <?php /* $Id: affiliate_banners_build.php,v 1.0 2003/04/29 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); if (!tep_session_is_registered('affiliate_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_AFFILIATE, '', 'SSL')); } require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_AFFILIATE_BANNERS_BUILD); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_AFFILIATE_BANNERS_BUILD)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <?php if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require(DIR_WS_INCLUDES . 'header_tags.php'); } else { ?> <title><?php echo TITLE ?></title> <?php } ?> <base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" height="28" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td align="right"><?php echo tep_image(DIR_WS_IMAGES . 'affiliate_links.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> <tr> <td colspan=2 class="main"><?php echo TEXT_INFORMATION; ?></td> </tr> </table> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <table width="95%" align="center" border="0" cellpadding="4" cellspacing="0" class="infoBoxContents"> <tr> <td class="infoBoxHeading" align="center"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER . ' ' . $affiliate_banners['affiliate_banners_title']; ?></td> </tr> <td class="smallText" align="center"> <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="smallText" align="right"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_INFO; ?></td> <td><?php echo tep_draw_form('individual_banner', tep_href_link(FILENAME_AFFILIATE_BANNERS_BUILD)); ?></td> <td><?php echo tep_draw_products_pull_down('individual_banner_id', 'style="font-size:10px"'); ?></td> <td><?php echo tep_image_submit('button_affiliate_build_a_link.gif', IMAGE_BUTTON_BUILD_A_LINK); ?></form></td> </tr> </table> </td> </tr> <?php if (tep_not_null($HTTP_POST_VARS['individual_banner_id']) || tep_not_null($HTTP_GET_VARS['individual_banner_id'])) { if (tep_not_null($HTTP_POST_VARS['individual_banner_id'])) $individual_banner_id = $HTTP_POST_VARS['individual_banner_id']; if ($HTTP_GET_VARS['individual_banner_id']) $individual_banner_id = $HTTP_GET_VARS['individual_banner_id']; $affiliate_banners_values = tep_db_query("select * from " . TABLE_AFFILIATE_BANNERS . " where affiliate_products_id ='". $individual_banner_id ."'"); if ($affiliate_banners = tep_db_fetch_array($affiliate_banners_values)) { $affiliate_products_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $affiliate_banners['affiliate_products_id'] . "' and language_id = '" . $languages_id . "'"); $affiliate_products = tep_db_fetch_array($affiliate_products_query); $prod_id = $affiliate_banners['affiliate_products_id']; $ban_id = $affiliate_banners['affiliate_banners_id']; switch (AFFILIATE_KIND_OF_BANNERS) { case 1: // Link to Products if ($prod_id > 0) { $link = '<a href="' . HTTPS_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank"><img src="' . HTTPS_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $affiliate_banners['affiliate_banners_image'] . '" border="0" alt="' . $affiliate_products['products_name'] . '"></a>'; $link1 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $affiliate_banners['affiliate_banners_image'] . '" border="0" alt="' . $affiliate_products['products_name'] . '"></a>'; $link2 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank">' . $affiliate_products['products_name'] . '</a>'; } break; case 2: // Link to Products if ($prod_id > 0) { $link = '<a href="' . HTTPS_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank"><img src="' . HTTPS_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_SHOW_BANNER . '?ref=' . $affiliate_id . '&affiliate_banner_id=' . $ban_id . '" border="0" alt="' . $affiliate_products['products_name'] . '"></a>'; $link1 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_SHOW_BANNER . '?ref=' . $affiliate_id . '&affiliate_banner_id=' . $ban_id . '" border="0" alt="' . $affiliate_products['products_name'] . '"></a>'; $link2 = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?ref=' . $affiliate_id . '&products_id=' . $prod_id . '&affiliate_banner_id=' . $ban_id . '" target="_blank">' . $affiliate_products['products_name'] . '</a>'; } break; } } if ($prod_id > 0) { ?> <tr> <td class="smallText" align="center"><?php echo $link1; ?></td> </tr> <tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INFO; ?></td> </tr> <tr> <td class="smallText" align="center"> <textarea cols="60" rows="6" class="boxText"><?php echo $link1; ?></textarea> </td> </tr> <tr> <td> <td> </tr> <tr> <td class="smallText" align="center"><b>Text Version:</b> <?php echo $link2; ?></td> </tr> <tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INFO; ?></td> </tr> <tr> <td class="smallText" align="center"> <textarea cols="60" rows="6" class="boxText"><?php echo $link2; ?></textarea> </td> </tr> <tr> <td> <td> </tr> <?php } } ?> </td> </tr> </table> </td> </tr> </table></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Quote
walkman Posted August 13, 2006 Posted August 13, 2006 Ok, I tried the above code and it wouldn't work, so I also did a patch to get it to work with the version 2.6 file -- "affiliate_banners_build.php" . Here is the important code to get a drop down of products instead of the popup window: ---------- replace this code around line 81 ---------------------------- <tr> <td class="smallText" align="center"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_INFO . tep_draw_form('individual_banner', tep_href_link(FILENAME_AFFILIATE_BANNERS_BUILD) ) . "\n" . tep_draw_input_field('individual_banner_id', '', 'size="5"') . " " . tep_image_submit('button_affiliate_build_a_link.gif', IMAGE_BUTTON_BUILD_A_LINK); ?></form></td> </tr> <tr> <td class="smallText" align="center"><?php echo '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_AFFILIATE_VALIDPRODUCTS) . '\')"><b>' . TEXT_AFFILIATE_VALIDPRODUCTS . '</b></a>'; ?> <?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_VIEW;?><br><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_HELP;?></td> </tr> <tr> ---------------- with this code ---------------------------------------------------------------------- <tr> <td class="smallText" align="center"><table width="100%" align="center" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="smallText" align="right"><?php echo TEXT_AFFILIATE_INDIVIDUAL_BANNER_INFO; ?></td> <td><?php echo tep_draw_form('individual_banner', tep_href_link(FILENAME_AFFILIATE_BANNERS_BUILD)); ?></td> <td><?php echo tep_draw_products_pull_down('individual_banner_id', 'style="font-size:10px"'); ?></td> <td><?php echo tep_image_submit('button_affiliate_build_a_link.gif', IMAGE_BUTTON_BUILD_A_LINK); ?></form></td> </tr> </table></td> </tr> ---------------------------------------------------------------------------------------- -- Note that of the two functions mentioned earlier I already had one of them installed, so I just added the other one to affiliate_functions.php. Check to see what you already have. -- Also, note you will want to make a similar change to the affiliate_banners_build_cat.php file. Quote
walkman Posted August 13, 2006 Posted August 13, 2006 Ok, I decided to post a copy of the tep_draw_categories_pull_down function that would be needed to add the same functionality for the build_category_link. (this is just a mod of the above product function) --------- I added this to affiliate_functions ---------------------- function tep_draw_categories_pull_down($name, $parameters = '', $exclude = '') { global $currencies, $languages_id; if ($exclude == '') { $exclude = array(); } $select_string = '<select name="' . $name . '"'; if ($parameters) { $select_string .= ' ' . $parameters; } $select_string .= '>'; $categories_query = tep_db_query("select p.categories_id, pd.categories_name from " . TABLE_CATEGORIES . " p, " . TABLE_CATEGORIES_DESCRIPTION . " pd where p.categories_id = pd.categories_id and pd.language_id = '" . (int)$languages_id . "' order by categories_name "); while ($categories = tep_db_fetch_array($categories_query)) { if (!in_array($categories['categories_id'], $exclude)) { $select_string .= '<option value="' . $categories['categories_id'] . '">' . $categories['categories_name'] . '</option>'; } } $select_string .= '</select>'; return $select_string; } ------------------------------------------------------------- Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.