Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

multiple drop down category navigation


thrasha

Recommended Posts

Well, remember that it's not yet final version!!!

 

/categories/includes/boxes/categories_js.php

<!--search//-->
</script>
  <tr>
           <td>
<?php
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
                              'text'  => BOX_HEADING_SEARCH
                             );
 new infoBoxHeading($info_box_contents, false, true);
$keywords="";
 $hide = tep_hide_session_id();
?>
<head>
 <script language="javascript" src="jsrsClient.js"></script>
 <script language="javascript" src="selectphp.js"></script>
</head>

<body bgcolor="#dddddd" onload="body_onLoad();" onhelp="jsrsDebugInfo();return false;"></body>
<?php

   echo tep_draw_form('QForm', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"') . tep_hide_session_id(); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
               <td class="fieldKey"><?php echo "Fabricantes"; ?></td>
               <td class="fieldValue"><?php echo tep_draw_pull_down_menu('manufacturers_id', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))); ?></td>
             </tr>

      <tr>
               <td class="fieldKey"><?php echo "Categorías"; ?></td>
               <td class="fieldValue"><?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))); ?></td>
             </tr>
             <tr>
               <td class="fieldKey"><?php echo "Subcategorías"; ?></td>
               <td class="fieldValue"><?php echo tep_draw_pull_down_menu('subcategories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))); ?></td>
             </tr>

             <tr>
               <td colspan="3" class="fieldKey"><?php echo "Palabras clave"; ?></td>
             </tr>
               <td colspan="2" class="boxText"><?php echo tep_draw_input_field('keywords','','style="width:100%"'); ?></td>

             <tr>
               <td colspan="1" align="left" class="boxText"><?php echo tep_draw_checkbox_field('search_in_description', '1') . ' ' . TEXT_SEARCH_IN_DESCRIPTION; ?></td>
 <input type="hidden" name="inc_subcat" value="1">
           <td colspan="2" class="smallText" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH); ?></td>
      </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>

   </table></form>


           </td>
         </tr>
<!-- search_eof //-->




<script>

 

/categories/jsrsClient.js

//
//  jsrsClient.js - javascript remote scripting client include
//  
//  Author:  Brent Ashley [[email protected]]
//
//  make asynchronous remote calls to server without client page refresh
//
//  see license.txt for copyright and license information

/*
see history.txt for full history
2.0  26 Jul 2001 - added POST capability for IE/MOZ
2.2  10 Aug 2003 - added Opera support
2.3(beta)  10 Oct 2003 - added Konqueror support - **needs more testing**
*/

// callback pool needs global scope
var jsrsContextPoolSize = 0;
var jsrsContextMaxPool = 10;
var jsrsContextPool = new Array();
var jsrsBrowser = jsrsBrowserSniff();
var jsrsPOST = true;
var containerName;

// constructor for context object
function jsrsContextObj( contextID ){
 
 // properties
 this.id = contextID;
 this.busy = true;
 this.callback = null;
 this.container = contextCreateContainer( contextID );
 
 // methods
 this.GET = contextGET;
 this.POST = contextPOST;
 this.getPayload = contextGetPayload;
 this.setVisibility = contextSetVisibility;
}

//  method functions are not privately scoped 
//  because Netscape's debugger chokes on private functions
function contextCreateContainer( containerName ){
 // creates hidden container to receive server data 
 var container;
 switch( jsrsBrowser ) {
   case 'NS':
     container = new Layer(100);
     container.name = containerName;
     container.visibility = 'hidden';
     container.clip.width = 100;
     container.clip.height = 100;
     break;
   
   case 'IE':
     document.body.insertAdjacentHTML( "afterBegin", '<span id="SPAN' + containerName + '"></span>' );
     var span = document.all( "SPAN" + containerName );
     var html = '<iframe name="' + containerName + '" src=""></iframe>';
     span.innerHTML = html;
     span.style.display = 'none';
     container = window.frames[ containerName ];
     break;

   case 'MOZ':  
     var span = document.createElement('SPAN');
     span.id = "SPAN" + containerName;
     document.body.appendChild( span );
     var iframe = document.createElement('IFRAME');
     iframe.name = containerName;
     iframe.id = containerName;
     span.appendChild( iframe );
     container = iframe;
     break;

   case 'OPR':  
     var span = document.createElement('SPAN');
     span.id = "SPAN" + containerName;
     document.body.appendChild( span );
     var iframe = document.createElement('IFRAME');
     iframe.name = containerName;
     iframe.id = containerName;
     span.appendChild( iframe );
     container = iframe;
     break;

   case 'KONQ':
     var span = document.createElement('SPAN');
     span.id = "SPAN" + containerName;
     document.body.appendChild( span );
     var iframe = document.createElement('IFRAME');
     iframe.name = containerName;
     iframe.id = containerName;
     span.appendChild( iframe );
     container = iframe;

     // Needs to be hidden for Konqueror, otherwise it'll appear on the page
     span.style.display = none;
     iframe.style.display = none;
     iframe.style.visibility = hidden;
     iframe.height = 0;
     iframe.width = 0;

     break;
 }
 return container;
}

function contextPOST( rsPage, func, parms ){

 var d = new Date();
 var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
 var doc = (jsrsBrowser == "IE" ) ? this.container.document : this.container.contentDocument;
 doc.open();
 doc.write('<html><body>');
 doc.write('<form name="jsrsForm" method="post" target="" ');
 doc.write(' action="' + rsPage + '?U=' + unique + '">');
 doc.write('<input type="hidden" name="C" value="' + this.id + '">');

 // func and parms are optional
 if (func != null){
 doc.write('<input type="hidden" name="F" value="' + func + '">');

   if (parms != null){
     if (typeof(parms) == "string"){
       // single parameter
       doc.write( '<input type="hidden" name="P0" '
                + 'value="[' + jsrsEscapeQQ(parms) + ']">');
     } else {
       // assume parms is array of strings
       for( var i=0; i < parms.length; i++ ){
         doc.write( '<input type="hidden" name="P' + i + '" '
                  + 'value="[' + jsrsEscapeQQ(parms[i]) + ']">');
       }
     } // parm type
   } // parms
 } // func

 doc.write('</form></body></html>');
 doc.close();
 doc.forms['jsrsForm'].submit();
}

function contextGET( rsPage, func, parms ){

 // build URL to call
 var URL = rsPage;

 // always send context
 URL += "?C=" + this.id;

 // func and parms are optional
 if (func != null){
   URL += "&F=" + escape(func);

   if (parms != null){
     if (typeof(parms) == "string"){
       // single parameter
       URL += "&P0=[" + escape(parms+'') + "]";
     } else {
       // assume parms is array of strings
       for( var i=0; i < parms.length; i++ ){
         URL += "&P" + i + "=[" + escape(parms[i]+'') + "]";
       }
     } // parm type
   } // parms
 } // func

 // unique string to defeat cache
 var d = new Date();
 URL += "&U=" + d.getTime();

 // make the call
 switch( jsrsBrowser ) {
   case 'NS':
     this.container.src = URL;
     break;
   case 'IE':
     this.container.document.location.replace(URL);
     break;
   case 'MOZ':
     this.container.src = '';
     this.container.src = URL; 
     break;
   case 'OPR':
     this.container.src = '';
     this.container.src = URL;
     break;
   case 'KONQ':
     this.container.src = '';
     this.container.src = URL; 
     break;
 }  
}

function contextGetPayload(){
 switch( jsrsBrowser ) {
   case 'NS':
     return this.container.document.forms['jsrs_Form'].elements['jsrs_Payload'].value;
   case 'IE':
     return this.container.document.forms['jsrs_Form']['jsrs_Payload'].value;
   case 'MOZ':
     return window.frames[this.container.name].document.forms['jsrs_Form']['jsrs_Payload'].value; 
   case 'OPR':
     var textElement = window.frames[this.container.name].document.getElementById("jsrs_Payload");
   case 'KONQ':
     var textElement = window.frames[this.container.name].document.getElementById("jsrs_Payload");
     return textElement.value;
 }  
}

function contextSetVisibility( vis ){
 switch( jsrsBrowser ) {
   case 'NS':
     this.container.visibility = (vis)? 'show' : 'hidden';
     break;
   case 'IE':
     document.all("SPAN" + this.id ).style.display = (vis)? '' : 'none';
     break;
   case 'MOZ':
     document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
   case 'OPR':
     document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
     this.container.width = (vis)? 250 : 0;
     this.container.height = (vis)? 100 : 0;
     break;
 }  
}

// end of context constructor

function jsrsGetContextID(){
 var contextObj;
 for (var i = 1; i <= jsrsContextPoolSize; i++){
   contextObj = jsrsContextPool[ 'jsrs' + i ];
   if ( !contextObj.busy ){
     contextObj.busy = true;      
     return contextObj.id;
   }
 }
 // if we got here, there are no existing free contexts
 if ( jsrsContextPoolSize <= jsrsContextMaxPool ){
   // create new context
   var contextID = "jsrs" + (jsrsContextPoolSize + 1);
   jsrsContextPool[ contextID ] = new jsrsContextObj( contextID );
   jsrsContextPoolSize++;
   return contextID;
 } else {
   alert( "jsrs Error:  context pool full" );
   return null;
 }
}

function jsrsExecute( rspage, callback, func, parms, visibility ){
 // call a server routine from client code
 //
 // rspage      - href to asp file
 // callback    - function to call on return
 //               or null if no return needed
 //               (passes returned string to callback)
 // func        - sub or function name  to call
 // parm        - string parameter to function
 //               or array of string parameters if more than one
 // visibility  - optional boolean to make container visible for debugging

 // get context
 var contextObj = jsrsContextPool[ jsrsGetContextID() ];
 contextObj.callback = callback;

 var vis = (visibility == null)? false : visibility;
 contextObj.setVisibility( vis );

 if ( jsrsPOST && ((jsrsBrowser == 'IE') || (jsrsBrowser == 'MOZ'))){
   contextObj.POST( rspage, func, parms );
 } else {
   contextObj.GET( rspage, func, parms );
 }
 
 return contextObj.id;
}

function jsrsLoaded( contextID ){
 // get context object and invoke callback
 var contextObj = jsrsContextPool[ contextID ];
 if( contextObj.callback != null){
   contextObj.callback( jsrsUnescape( contextObj.getPayload() ), contextID );
 }
 // clean up and return context to pool
 contextObj.callback = null;
 contextObj.busy = false;
}

function jsrsError( contextID, str ){
 alert( unescape(str) );
 jsrsContextPool[ contextID ].busy = false
}

function jsrsEscapeQQ( thing ){
 return thing.replace(/'"'/g, '\\"');
}

function jsrsUnescape( str ){
 // payload has slashes escaped with whacks
 return str.replace( /\\\//g, "/" );
}

function jsrsBrowserSniff(){
 if (document.layers) return "NS";
 if (document.all) {
 // But is it really IE?
 // convert all characters to lowercase to simplify testing
 var agt=navigator.userAgent.toLowerCase();
 var is_opera = (agt.indexOf("opera") != -1);
 var is_konq = (agt.indexOf("konqueror") != -1);
 if(is_opera) {
	 return "OPR";
 } else {
	 if(is_konq) {
   return "KONQ";
	 } else {
   // Really is IE
   return "IE";
	 }
 }
 }
 if (document.getElementById) return "MOZ";
 return "OTHER";
}

/////////////////////////////////////////////////
//
// user functions

function jsrsArrayFromString( s, delim ){
 // rebuild an array returned from server as string
 // optional delimiter defaults to ~
 var d = (delim == null)? '~' : delim;
 return s.split(d);
}

function jsrsDebugInfo(){
 // use for debugging by attaching to f1 (works with IE)
 // with onHelp = "return jsrsDebugInfo();" in the body tag
 var doc = window.open().document;
 doc.open;
 doc.write( 'Pool Size: ' + jsrsContextPoolSize + '<br><font face="arial" size="2"><b>' );
 for( var i in jsrsContextPool ){
   var contextObj = jsrsContextPool[i];
   doc.write( '<hr>' + contextObj.id + ' : ' + (contextObj.busy ? 'busy' : 'available') + '<br>');
   doc.write( contextObj.container.document.location.pathname + '<br>');
   doc.write( contextObj.container.document.location.search + '<br>');
   doc.write( '<table border="1"><tr><td>' + contextObj.container.document.body.innerHTML + '</td></tr></table>' );
 }
 doc.write('</table>');
 doc.close();
 return false;
}

/categories/jsrsServer.php.inc

<?php

//
// jsrsServer.php - javascript remote scripting server include
//
// Orginal Author:  Brent Ashley [[email protected]]
// PHP version   :  S?bastien Cramatte [[email protected]] 
//      Pierre Cailleux [[email protected]] 
// Date   :  May 2001
// 
// see jsrsClient.js for version info
//
//  see license.txt for copyright and license info

function jsrsDispatch($validFuncs ){
 $func = jsrsBuildFunc($validFuncs);
 
 if ($func != ""){
   $retval;
   
   eval("\$retval =  " . $func . ";");
   
   if (strlen($retval)>0){
     jsrsReturn($retval."");
   } else {
     jsrsReturn("");
   } 
 } else {
   jsrsReturnError("function builds as empty string");
 }
}

function jsrsReturn($payload) {
 global $C;
 if(!isset($C)) $C = (isset($_REQUEST['C']) ? $_REQUEST['C'] : "");

 Print (
     "<html><head></head><body onload=\"p=document.layers?parentLayer:window.parent;p.jsrsLoaded('" 
   . $C . "');\">jsrsPayload:<br>" 
   . "<form name=\"jsrs_Form\"><textarea name=\"jsrs_Payload\" id=\"jsrs_Payload\">"
   . jsrsEscape($payload) . "</textarea></form></body></html>");
   exit();
}

function jsrsEscape($str){
 // escape ampersands so special chars aren't interpreted
 $tmp = ereg_replace( "&", "&", $str );
 // escape slashes  with whacks so end tags don't interfere with return html
 return ereg_replace( "\/" , "\\/",$tmp); 
}

/////////////////////////////
//
// user functions


function jsrsReturnError($str){
 global $C;
 if(!isset($C)) $C = (isset($_REQUEST['C']) ? $_REQUEST['C'] : "");
 
 // escape quotes
 $cleanStr = ereg_replace("\'","\\'",$str);
 
 // !!!! --- Warning -- !!!
 $cleanStr = "jsrsError: " . ereg_replace("\"", "\\\"", $cleanStr); 
 print ("<html><head></head><body " 
        . "onload=\"p=document.layers?parentLayer:window.parent;p.jsrsError('" . $C . "','" . urlencode($str) . "');\">"
        . $cleanStr . "</body></html>" );
 exit();
}

function jsrsArrayToString( $a, $delim ){
 // user function to flatten 1-dim array to string for return to client
 $d = "~";
 if (!isset($delim)) $d = $delim;
 return implode($a,$d); 
}


function jsrsBuildFunc($validFuncs) {
global $F;
if(!isset($F)) $F = (isset($_REQUEST['F']) ? $_REQUEST['F'] : "");

$func = ""; 

if ($F != "") {
 $func = $F;
 
     
 // make sure it's in the dispatch list
 if (strpos(strtoupper($validFuncs),strtoupper($func))===false)
    jsrsReturnError($func . " is not a valid function" );
  
  $func .= "(";
  $i = 0;
   
  //--- To optimize ! --- 
  eval("global \$P$i;");
  eval("if(!isset(\$P$i)) \$P$i = (isset(\$_REQUEST['P$i']) ? \$_REQUEST['P$i']:'');");
  $Ptmp = "P". $i;
    
  while ($$Ptmp!="") {
   $parm = $$Ptmp;
   $parm = substr($parm,1,strlen($parm)-2);
   $func .= "\"" . $parm . "\",";
   $i++;
   eval("global \$P$i;");
   eval("if(!isset(\$P$i)) \$P$i = (isset(\$_REQUEST['P$i']) ? \$_REQUEST['P$i']:'');");
   $Ptmp = "P". $i;
  }
  
  if (substr($func,strlen($func)-1,1)==",")  
   $func = substr($func,0,strlen($func)-1);

   $func .= ")";
 } 

return $func;
}

function jsrsEvalEscape($thing) {
$tmp = ereg_replace($thing,"\r\n","\n");
return $tmp;
}

function jsrsVBArrayToString($a,$delim) {
// --- not use in PHP see jsrsArrayToString method
return jsrsArrayToString($a,$delim);
}


?>

/categories/select_rs.php

<?php

require("jsrsServer.php.inc");
jsrsDispatch( "categoriesList subcategoriesList manufacturersList" );

function manufacturersList( $subcategoriesID ){

/*if ($subcategoriesID==null){ */ return serializeSql("select manufacturers_id, manufacturers_name from manufacturers order by manufacturers_name");
//}
}
function categoriesList($manufacturersID) {
if ($manufacturersID==null){

 return serializeSql( "select c.categories_id, cd.categories_name from categories c,categories_description cd where c.categories_id=cd.categories_id and c.parent_id=0 and cd.language_id=3 order by categories_name" );
}

else{

return serializeSql( "select distinct c.parent_id, cd.categories_name from categories c,categories_description cd, products p, products_to_categories ptc, manufacturers m where m.manufacturers_id = " . $manufacturersID . " and p.manufacturers_id = m.manufacturers_id and ptc.products_id=p.products_id and c.categories_id = ptc.categories_id and cd.language_id=3 and c.parent_id=cd.categories_id order by categories_name" ); }
}

function subcategoriesList($manufacturersID_aux='',$categoriesID){
if ($categoriesID==null){
continue;
}
else{
if($manufacturersID_aux!=''){
  return serializeSql( "select distinct c.categories_id, cd.categories_name from categories c,categories_description cd, products p, products_to_categories ptc, manufacturers m where p.manufacturers_id = " . $manufacturersID_aux . " and ptc.products_id=p.products_id and  c.categories_id=ptc.categories_id and cd.language_id=3 and c.parent_id=" . $categoriesID . " and cd.categories_id=c.categories_id order by categories_name" );
}
else{
return serializeSql("select c.categories_id, cd.categories_name from categories c,categories_description cd where c.categories_id=cd.categories_id and c.parent_id=" . $categoriesID . " and cd.language_id=3 order by categories_name");
}
}
}





function serializeSql( $sql ){

 $link = mysql_connect("server", "user", "password");
 mysql_select_db ("oscmenu_es_db");

 $result = mysql_query ($sql);
 $s = '';
 while ($row = mysql_fetch_row($result)) {
  $s .= join( $row, '~') . "|";
 }

 mysql_close($link);
 return $s;
}



?>

/categories/selectphp.js

// constants
var noValue = '';
var fab_lleno='0';
var cat_lleno='0';
var cat_limpiar_activado="0";
// globals
var curOption = new Array();
var isLoaded = new Array();

function body_onLoad(){
 // initialize lists
 emptyList( 'categories_id' );
 emptyList( 'subcategories_id');
 emptyList( 'manufacturers_id' );

 jsrsExecute( 'select_rs.php', cbFillOptions, 'manufacturersList' );
 jsrsExecute( 'select_rs.php', cbFillMake, 'categoriesList' );
//  jsrsExecute( 'select_rs.php', cbFillModel, 'subcategoriesList' );

}

function manufacturers_id_onChange(){
 var val = this.options[this.selectedIndex].value;
 if(val == noValue){

   emptyList( 'categories_id' );
   emptyList( 'subcategories_id' );
   window.status = 'cargando categor?as...';
   jsrsExecute( 'select_rs.php', cbFillOptions, 'manufacturersList' );
   jsrsExecute( 'select_rs.php', cbFillMake, 'categoriesList' );

   // don't allow novalue selection - revert to current
   //selectOption( this.name, curOption[this.name] )
 } else {
 fab_lleno="1";
 curOption[this.name] = val;
   // init dependent lists
   emptyList( 'categories_id' );
   emptyList( 'subcategories_id' );
   window.status = 'cargando categor?as...';
   jsrsExecute( 'select_rs.php', cbFillMake, 'categoriesList', val );
 }
}

function categories_id_onChange(){
 var val = this.options[this.selectedIndex].value;
 var fabri=this.form.manufacturers_id.options[this.form.manufacturers_id.selectedIndex].value;

 if(val == noValue){
   if(cat_limpiar_activado=="1"){
emptyList( 'subcategories_id' );
jsrsExecute( 'select_rs.php', cbFillMake, 'categoriesList', fabri );
document.forms['QForm']['categories_id'].text = '-Contiene datos-';
cat_limpiar_activado="0";
   }

   // don't allow novalue selection - revert to current
   //selectOption( this.name, curOption[this.name] )
 } else {
   cat_lleno="1";
   curOption[this.name] = val;
   // init dependent lists
   emptyList( 'subcategories_id' );
  // emptyList( 'manufacturers_id');
   window.status = 'cargando subcategor?as...';
   jsrsExecute( 'select_rs.php', cbFillModel, 'subcategoriesList', Array(fabri,val) );
 }
}

function subcategories_id_onChange(){
/*  var val = this.options[this.selectedIndex].value;
 if(val == noValue){
   selectOption( this.name, curOption[this.name] )
 } else {
   curOption[this.name] = val;
   emptyList( 'manufacturers_id');
   window.status = 'Cargando fabricantes...';
   jsrsExecute( 'select_rs.php', cbFillOptions, 'manufacturersList', val );
 }
*/}


function cbFillMake ( strCategories ){
 window.status = '';
 fillList( 'categories_id',  strCategories );
}

function cbFillModel ( strSubcategories ){
 // callback for dependent listbox
 window.status = '';
 fillList( 'subcategories_id',  strSubcategories );
}

function cbFillOptions( strManufacturers ){
 // callback for dependent listbox
 window.status = '';
 fillList( 'manufacturers_id', strManufacturers );
}

function fillList( listName, strManufacturers ){
 // fill any list with options
 emptyList( listName );
 // always insert selection prompt
 var lst = document.forms['QForm'][listName];
lst.style.width=116;


if(fab_lleno=="1"){
document.forms['QForm']['manufacturers_id'].options[0].text = '--Limpiar datos--';
document.forms['QForm']['manufacturers_id'].options[0].style.color='blue';

lst.options[0] = new Option('-Contiene datos-', noValue);
lst.options[0].style.color='red';
fab_lleno="0";
}
else{ if (cat_lleno=="1"){
document.forms['QForm']['categories_id'].options[0].text = '--Limpiar datos--';
document.forms['QForm']['categories_id'].options[0].style.color='blue';

lst.options[0] = new Option('-Contiene datos-', noValue);
lst.options[0].style.color='red';

cat_lleno="0";
cat_limpiar_activado="1";
}

else{
 lst.options[0] = new Option('--Buscar todos--', noValue);
}
}
 // options in form "value~displaytext|value~displaytext|..."
 var aOptionPairs = strManufacturers.split('|');
 for( var i = 0; i < aOptionPairs.length; i++ ){
   if (aOptionPairs[i].indexOf('~') != -1) {
     var aOptions = aOptionPairs[i].split('~');
     lst.options[i + 1] = new Option(aOptions[1], aOptions[0]);
   }
 }

 // init to no value
 selectOption( listName, noValue );
 //isLoaded[listName] = true;
 lst.disabled = false;
 lst.onchange = eval( listName + "_onChange" );
 // eval( "document.forms['QForm']['" + listName + "'].onchange=" + listName + "_onChange;" );
}

function emptyList( listName ){
 var lst = document.forms['QForm'][listName];
 lst.options.length = 0;
//lst.style.width=50;
 lst.options.width=50;

 lst.onchange = null;
 isLoaded[listName] = false;
 curOption[listName] = noValue;
}

function selectOption( listName, optionVal ){
 // set list selection to option based on value
 var lst = document.forms['QForm'][listName];
 for( var i = 0; i< lst.options.length; i++ ){
   if( lst.options[i].value == optionVal ){
     lst.selectedIndex = i;
     curOption[listName] = optionVal;
     return;
   }
 }
}

 

/categories/includes/column_left.php

 

<?php
/*
 $Id: column_left.php,v 1.15 2003/07/01 14:34:54 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<td>

<script type='text/javascript'>
<!--
<?php

    if ((USE_CACHE == 'true') && empty($SID)) {
   echo tep_cache_categories_box();
 } else {
   include(DIR_WS_BOXES . 'categories_js.php');
 }

?>

//-->
</script>
<noscript>

<?php
 include(DIR_WS_BOXES . 'categories.php');
?>
</noscript>
<?php
 if ((USE_CACHE == 'true') && empty($SID)) {
   echo tep_cache_manufacturers_box();
 } else {
   include(DIR_WS_BOXES . 'manufacturers.php');
 }

 require(DIR_WS_BOXES . 'whats_new.php');
 require(DIR_WS_BOXES . 'search.php');
 require(DIR_WS_BOXES . 'information.php');
?>

 

I Don't remember if I modified more files like advanced_search.php or advanced_search_result.php, if you have problem post it.

 

There are the steps to do:

-I'd like that the menu where disabled if browser don't accept javascript.

-More languages

-Clean the code (arggg, it's horrible)

-Ideas????

Link to comment
Share on other sites

Well, I think I modified the advanced_search_result.php here is the code:

<?php
/*
 $Id: advanced_search_result.php,v 1.72 2003/06/23 06:50:11 project3000 Exp $

 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');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 $error = false;

 if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&
      (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&
      (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&
      (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&
      (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {
   $error = true;

   $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
 } else {
   $dfrom = '';
   $dto = '';
   $pfrom = '';
   $pto = '';
   $keywords = '';

   if (isset($HTTP_GET_VARS['dfrom'])) {
     $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);
   }

   if (isset($HTTP_GET_VARS['dto'])) {
     $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);
   }

   if (isset($HTTP_GET_VARS['pfrom'])) {
     $pfrom = $HTTP_GET_VARS['pfrom'];
   }

   if (isset($HTTP_GET_VARS['pto'])) {
     $pto = $HTTP_GET_VARS['pto'];
   }

   if (isset($HTTP_GET_VARS['keywords'])) {
     $keywords = $HTTP_GET_VARS['keywords'];

   }


   $date_check_error = false;
   if (tep_not_null($dfrom)) {
     if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {
       $error = true;
       $date_check_error = true;

       $messageStack->add_session('search', ERROR_INVALID_FROM_DATE);
     }
   }

   if (tep_not_null($dto)) {
     if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {
       $error = true;
       $date_check_error = true;

       $messageStack->add_session('search', ERROR_INVALID_TO_DATE);
     }
   }

   if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {
     if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {
       $error = true;

       $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);
     }
   }

   $price_check_error = false;
   if (tep_not_null($pfrom)) {
     if (!settype($pfrom, 'double')) {
       $error = true;
       $price_check_error = true;

       $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);
     }
   }

   if (tep_not_null($pto)) {
     if (!settype($pto, 'double')) {
       $error = true;
       $price_check_error = true;

       $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);
     }
   }

   if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {
     if ($pfrom >= $pto) {
       $error = true;

       $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);
     }
   }

   if (tep_not_null($keywords)) {
     if (!tep_parse_search_string($keywords, $search_keywords)) {
       $error = true;

       $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);
     }
   }
   if(!tep_not_null($keywords)) {
   $keywords="hack";
   }

 }

 if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
   $error = true;

   $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
 }

 if ($error == true) {
   tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false));
 }

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false));
?>
<!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; ?>">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<title><?php echo TITLE; ?></title>
<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; ?>" 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><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php
// create column list
 $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                      'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                      'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                      'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                      'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                      'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                      'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                      'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

 asort($define_list);

 $column_list = array();
 reset($define_list);
 while (list($key, $value) = each($define_list)) {
   if ($value > 0) $column_list[] = $key;
 }

 $select_column_list = '';

 for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
   switch ($column_list[$i]) {
     case 'PRODUCT_LIST_MODEL':
       $select_column_list .= 'p.products_model, ';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $select_column_list .= 'm.manufacturers_name, ';
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $select_column_list .= 'p.products_quantity, ';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $select_column_list .= 'p.products_image, ';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $select_column_list .= 'p.products_weight, ';
       break;
   }
 }

 $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
 }

 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   if (!tep_session_is_registered('customer_country_id')) {
     $customer_country_id = STORE_COUNTRY;
     $customer_zone_id = STORE_ZONE;
   }
   $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
 }

 $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";

 if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) {
   if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) {
     $subcategories_array = array();
if (isset($HTTP_GET_VARS['subcategories_id']) && tep_not_null($HTTP_GET_VARS['subcategories_id'])) {
     tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['subcategories_id']);

     $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['subcategories_id'] . "'";
}
else {
     tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']);

     $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";
}
     for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
       $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'";
     }

     $where_str .= ")";
   } else {
     $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";
   }
 }

 if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
   $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
 }

 if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
   $where_str .= " and (";
   for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
     switch ($search_keywords[$i]) {
       case '(':
       case ')':
       case 'and':
       case 'or':
         $where_str .= " " . $search_keywords[$i] . " ";
         break;
       default:
         $keyword = tep_db_prepare_input($search_keywords[$i]);
         $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
         if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
         $where_str .= ')';
         break;
     }
   }
   $where_str .= " )";
 }

 if (tep_not_null($dfrom)) {
   $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'";
 }

 if (tep_not_null($dto)) {
   $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'";
 }

 if (tep_not_null($pfrom)) {
   if ($currencies->is_set($currency)) {
     $rate = $currencies->get_value($currency);

     $pfrom = $pfrom / $rate;
   }
 }

 if (tep_not_null($pto)) {
   if (isset($rate)) {
     $pto = $pto / $rate;
   }
 }

 if (DISPLAY_PRICE_WITH_TAX == 'true') {
   if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")";
   if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")";
 } else {
   if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")";
   if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")";
 }

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   $where_str .= " group by p.products_id, tr.tax_priority";
 }

 if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
   for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
     if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
       $HTTP_GET_VARS['sort'] = $i+1 . 'a';
       $order_str = ' order by pd.products_name';
       break;
     }
   }
 } else {
   $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
   $sort_order = substr($HTTP_GET_VARS['sort'], 1);
   $order_str = ' order by ';
   switch ($column_list[$sort_col-1]) {
     case 'PRODUCT_LIST_MODEL':
       $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_NAME':
       $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_IMAGE':
       $order_str .= "pd.products_name";
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_PRICE':
       $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
   }
 }

 $listing_sql = $select_str . $from_str . $where_str . $order_str;

 require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);
?>
       </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></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'); ?>

Link to comment
Share on other sites

If anyone get errors post here.

 

Remember that it's Beta contribution for Oscommerce 2.2 MS2, it's possible that it have security bugs for that reason I have not published at the Oscommerce website.

 

What do you think about this contribution?

 

If do you like this contribution please help us to make it more stable!

 

Thanks for replies and pardon for my horrible english and ask if don't understand me :-D

Link to comment
Share on other sites

I modified selectphp.js and categories_js.php to preserve the selections doing searches.

You can download the contriution from here:

 

http://usuarios.lycos.es/oscmenu/dropdownm...ropdownmenu.zip

If this link redirect you to another lycos webpage, click with right button --> "Save link as"

To install the contribution:

 

-Backup your files.

-Copy the dropdown menu in their folders (same as the zip)

-Modify "select_rs.php" file with your information for the database: "user", "password", "server" and "database name".

 

I have tested it with Mozilla Firebird 0.6.1

 

I accept all type of suggestions and contributions.

Link to comment
Share on other sites

  • 2 weeks later...

Where can we download this? (the old links don't work) Why not just add it to the contributions section?

 

The contribution seems to work find in Mozilla. However, what is the text that shows up as 'clean data' and 'contains data' in the drop down?

Edited by safoo
Link to comment
Share on other sites

Ok lycos.co.uk goes well

 

Here to preview: http://members.lycos.co.uk/oscmenu

Here to download: http://members.lycos.co.uk/oscmenu/dropdownmenu

 

When you click in manufacturer, new line adds to the list (clean data) and new line to the categories (contains data). The "clean data" command will reset the lists, and the "contains data" command is only for advertise the client that the list has been charged.

 

Thx for reply

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...