Re: Product Finder: multiple category drop-downs
they are up now, I had turned the sidebox off last night and forgot to turn it back on, my fault.
Also I have edited the product_finder_defines.php in inlcudes/languages/english/extra_definitions/My_Template to read this
Also I have noticed that the Go, buttons are not showing up any insight on how I could get those to work, it looks really good on other site I have seen with it working, however even when I am just using 3 drop downs, and they are fully working I still get no "go" buttons.
Thanks
J
PHP Code:
<?php
/**
* blank sidebox definitions - text for inclusion in a new blank sidebox
*
* @package templateSystem
* @copyright 2007 Kuroi Web Design
* @copyright Portions Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: blank_sidebox.php 2007-05-26 kuroi $
*/
define('TEXT_MAKE', 'Year:');
define('TEXT_MODEL', 'Make:');
define('TEXT_YEAR', 'Model:');
define('TEXT_PLEASE_SELECT', 'Please Select');
define('TEXT_FIND_ALL_PRODUCTS', '');
define('PF_NOSCRIPT_SUBMIT', 'go.gif');//in templates/Custom_template/buttons/english/
define('BOX_HEADING_PRODUCT_FINDER', 'Shop by Vehicle');
define('TEXT_BLANK_SIDEBOX', '');
?>
Re: Product Finder: multiple category drop-downs
Sorry, just noticed I pasted the orgiinal code not mine so I changed it from this ^^^^ above. to this
PHP Code:
<?php
/**
* blank sidebox definitions - text for inclusion in a new blank sidebox
*
* @package templateSystem
* @copyright 2007 Kuroi Web Design
* @copyright Portions Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: blank_sidebox.php 2007-05-26 kuroi $
*/
define('TEXT_MAKE', 'Make:');
define('TEXT_MODEL', 'Model:');
define('TEXT_YEAR', 'Year:');
define('TEXT_ENGINE', 'Engine:');
define('TEXT_PLEASE_SELECT', 'Please Select');
define('TEXT_FIND_ALL_PRODUCTS', '');
define('PF_NOSCRIPT_SUBMIT', 'go.gif');//in templates/TEMPLATE/buttons/english/
define('BOX_HEADING_PRODUCT_FINDER', 'Shop By Vehicle');
define('TEXT_BLANK_SIDEBOX', '');
?>
Re: Product Finder: multiple category drop-downs
working on this still, trying to get it done by the end of the day, however I am stumped. I am fairly confident I have the jquery and the tpl_product_finder file correct, however I am not sure what is wrong with the modellist.php file that goes in route I have modified it to what I think is right however I have limited understanding on how these things work and it is still not working, I am sure it is something maybe someone can offer up some help. Just for reference here is my site bullys performance dot com. and here are the 4 files that I have modified thus far, I am getting the 4 drop downs to apear, and the fist one is finding categories, however when something is selected it does not populate the second drop down.
First file modified located @ includes/languages/english/extra_definitions/Custom_Template/product_finder_defines.php
PHP Code:
<?php
/**
* blank sidebox definitions - text for inclusion in a new blank sidebox
*
* @package templateSystem
* @copyright 2007 Kuroi Web Design
* @copyright Portions Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: blank_sidebox.php 2007-05-26 kuroi $
*/
define('TEXT_MAKE', 'Year:');
define('TEXT_MODEL', 'Make:');
define('TEXT_YEAR', 'Model:');
define('TEXT_ENGINE', 'Engine:');
define('TEXT_PLEASE_SELECT', 'Please Select');
define('TEXT_FIND_ALL_PRODUCTS', '');
define('PF_NOSCRIPT_SUBMIT', 'includes/templates/theme584/buttons/english/go.gif');//in templates/TEMPLATE/buttons/english/
define('BOX_HEADING_PRODUCT_FINDER', 'Shop By Vehicle');
define('TEXT_BLANK_SIDEBOX', '');
?>
The second file I have modified is located @ /includes/templates/Custom_Template/jscript/jscript_model_year.php
Code:
<!-- Product Finder mod
/includes/templates/YOUR_TEMPLATE/jscript/jscript_model_year.php
@license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
@version $Id: jscript_model_year.php 2010-09-29-->
<script type="text/javascript"><!--
$(document).ready(function(){
$("#cPath").change(modelList);
$("#select_model").change(yearList);
$("#select_year").change(function()
//$("#select_engine").focus();
$("#select_engine").change(function()
{
var baseDirectory=document.getElementById("basemodulepath").value;
var cPath1=$("#cPath").val();
var cPath2=$("#select_model").val();
var cPath3=$("#select_year").val();
var cPath4=$("#select_engine").val();
window.location=(baseDirectory+"index.php?main_page=index&cPath="+cPath1+"_"+cPath2+"_"+cPath3+"_"+cPath4);
}
);
});
var modelList=function model_list(){
var baseDirectory=document.getElementById("basemodulepath").value;
var cPath=document.getElementById("cPath").value;
$.ajax({
type: 'POST',
url:baseDirectory+"modellist.php",
data:"cPath="+cPath+"&my=1",
success: function(data){
// alert(data);
if(data!=""){
arrayVar=new Array();
arrayVar=data.split("|");
arrayVarId=new Array();
arrayVarId=arrayVar[0].split("^");
arrayVarName=new Array();
arrayVarName=arrayVar[1].split("^");
$('#select_model').html("");
$('#select_model').append("<option value=''><?php echo TEXT_PLEASE_SELECT; ?><\/option>");
for(i=1;i<arrayVarId.length-1;i++)
{
$('#select_model').append($("<option><\/option>").attr("value",arrayVarId[i]).text(arrayVarName[i]));
}
}
}
});
};
var yearList=function year_list(){
var baseDirectory=document.getElementById("basemodulepath").value;
var cPath=document.getElementById("cPath").value;
$.ajax({
type: 'POST',
url:baseDirectory+"modellist.php",
data:"cPath="+cPath+"&my=1",
success: function(data){
// alert(data);
if(data!=""){
arrayVar=new Array();
arrayVar=data.split("|");
arrayVarId=new Array();
arrayVarId=arrayVar[0].split("^");
arrayVarName=new Array();
arrayVarName=arrayVar[1].split("^");
$('#select_year').html("");
$('#select_year').append("<option value=''><?php echo TEXT_PLEASE_SELECT; ?><\/option>");
for(i=1;i<arrayVarId.length-1;i++)
{
$('#select_year').append($("<option><\/option>").attr("value",arrayVarId[i]).text(arrayVarName[i]));
}
}
}
});
};
var engineList=function engine_list(){
var baseDirectory=document.getElementById("basemodulepath").value;
var cPath=document.getElementById("select_engine").value;
$.ajax({
type: 'POST',
url:baseDirectory+"modellist.php",
data:"cPath="+cPath+"&my=3",
success: function(data){
if(data!=""){
arrayVar=new Array();
arrayVar=data.split("|");
arrayVarId=new Array();
arrayVarId=arrayVar[0].split("^");
arrayVarName=new Array();
arrayVarName=arrayVar[1].split("^");
$('#select_engine').html("");
$('#select_engine').append("<option value=''><?php echo TEXT_PLEASE_SELECT; ?><\/option>");
for(i=1;i<arrayVarId.length-1;i++)
{
$('#select_engine').append($("<option><\/option>").attr("value",arrayVarId[i]).text(arrayVarName[i]));
}
}
}
});
};
//--></script>
The third file that I have modified is located @ includes/templates/Custom_Template/sideboxes/tpl_product_finder.php
PHP Code:
<?php
/**
* blank sidebox - allows a blank sidebox to be added to your site
*
* @package templateSystem
* @copyright 2007 Kuroi Web Design
* @copyright Portions Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: blank_sidebox.php 2007-05-26 kuroi $
*/
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
//$content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>';
//<!--BOF Product Finder-->
$content .= '<form action="">';
$content .= '<div>' . "\n" . '<div>';
$model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT);
if(isset($_REQUEST['cPath1'])){
$value=$_REQUEST['cPath1'];
}
$content .= '<span id="pf_title">'.strip_tags(TEXT_FIND_ALL_PRODUCTS).'</span>
<span class="pf_selectbox_name">'.TEXT_MAKE . "</span>" . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"');
$content .= '</div>' . "\n";
$content .= '<div class="pf_noscript">';
$content .= '<noscript>';
$content .= zen_my_image_submit(PF_NOSCRIPT_SUBMIT, "Go");
if($_REQUEST['cPath1']!=""){
$value=$_REQUEST['cPath1'];
$dropdownArray=zen_get_category_tree($value);
}
$content .= '</noscript>';
$content .= '</div>' . "\n";
$content .= '<div>';
$modulePath="".DIR_WS_CATALOG;
$content .= zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ');
$model=array();
$model[]=array('id'=>'',
'text'=>TEXT_PLEASE_SELECT
);
if($_REQUEST['cPath1']!=""){
$model=array_merge($model,$dropdownArray);
}
if(isset($_REQUEST['select_model'])){
$value=$_REQUEST['select_model'];
}
$content .= '<span class="pf_selectbox_name">' . TEXT_MODEL .'</span>'
. zen_draw_pull_down_menu('select_model', $model, $value, 'id="select_model" class="pf_selectbox_text"');
$content .= '</div>' . "\n";
$content .= '<div class="pf_noscript">';
$content .= '<noscript>';
if($_REQUEST['select_model']!=""){
$value=$_REQUEST['select_model'];
$dropdownArray=zen_get_category_tree($value);
}
$content .= zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
$content .= '</noscript>';
$content .= '</div>' . "\n";
$content .= '<div>';
$modulePath="".DIR_WS_CATALOG;
$content .= zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ');
$year=array();
$year[]=array('id'=>'',
'text'=>TEXT_PLEASE_SELECT
);
if($_REQUEST['cPath2']!=""){
$year=array_merge($year,$dropdownArray);
}
if(isset($_REQUEST['select_year'])){
$value=$_REQUEST['select_year'];
}
$content .= '<span class="pf_selectbox_name">' . TEXT_YEAR .'</span>'
. zen_draw_pull_down_menu('select_year', $year, $value, 'id="select_year" class="pf_selectbox_text"');
$content .= '</div>' . "\n";
$content .= '<div class="pf_noscript">';
$content .= '<noscript>';
if($_REQUEST['select_year']!=""){
$value=$_REQUEST['select_year'];
$dropdownArray=zen_get_category_tree($value);
}
$content .= zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
$content .= '</noscript>';
$content .= '</div>' . "\n";
$content .= '<div>';
$engine=array();
$engine[]=array('id'=>'',
'text'=>TEXT_PLEASE_SELECT
);
if($_REQUEST['select_year']!=""){
$engine=array_merge($engine,$dropdownArray);
}
if(isset($_REQUEST['cPath'])){
$value=$_REQUEST['cPath'];
}
if($_REQUEST['select_year']!=""){
$content .= '<span class="pf_selectbox_name">' . TEXT_ENGINE . '</span>' .
zen_draw_pull_down_menu('cPath',$engine , $value, 'id="select_engine" class="pf_selectbox_text"');
}
else {
$content .= '<span class="pf_selectbox_name">' . TEXT_ENGINE .'</span>' .
zen_draw_pull_down_menu('cPath22',$engine , $value, 'id="select_engine" class="pf_selectbox_text"');
}
$content .= '</div>' . "\n";
$content .= '<div class="pf_noscript">';
$content .= '<noscript>';
if($_REQUEST['cPath']!=""){
$value=$_REQUEST['cPath'];
}
$content .= zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
$content .= '</noscript>';
$content .= '</div>' . "\n";
$content .= '</div>';
$content .= '</form>';
//<!--EOF Product Finder-->
$content .= '</div>';
?>
and the 4th file I have modified is the modellist.php that is in the root folder of my store (this is the one I think that is wrong, but their might be some errors in the others above as well.
PHP Code:
<?php
/** Product Finder mod
* modellist.php
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: modellist.php 2010-09-29
*/
require('includes/application_top.php');
$manufacturers_id=$_REQUEST['cPath'];
if($_REQUEST['cPath']!=""){
$categories = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and c.parent_id = '".$manufacturers_id."'
order by c.sort_order, cd.categories_name";
$product_to_categories_query="select distinct categories_id from ".TABLE_PRODUCTS_TO_CATEGORIES;
$product_c_result=$db->Execute($product_to_categories_query);
$categories_array=array();
$inarray="";
$count=0;
while(!$product_c_result->EOF){
$categories_array[]= $product_c_result->fields['categories_id'];
if($count==0){
$inarray.=$product_c_result->fields['categories_id'];
}
else{
$inarray.=",".$product_c_result->fields['categories_id'];
}
$product_c_result->MoveNext();
$count=1;
}
$inarray=" IN (".$inarray.")";
$product_to_categories_query="select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' and c.categories_id ".$inarray."
order by c.sort_order, cd.categories_name";
$product_c_result=$db->Execute($product_to_categories_query);
$categories_array=array();
$inarray="";
$count=0;
while(!$product_c_result->EOF){
$categories_array[]= $product_c_result->fields['categories_id'];
$categories_array1[]= $product_c_result->fields['categories_name'];
$categories_array2[]= $product_c_result->fields['parent_id'];
$categories_array3[]= $product_c_result->fields['parent_id'];
$product_c_result->MoveNext();
}
$expected = $db->Execute($categories);
$ids="";
$name="";
$count=0;
while (!$expected->EOF) {
if(in_array($expected->fields['categories_id'],$categories_array3) ||in_array($expected->fields['categories_id'],$categories_array)){
if($count==0){
$ids="^";
$name="^";
}
$ids.=$expected->fields['categories_id']."^";
$name.=$expected->fields['categories_name']."^";
$count=1;
}
$expected->MoveNext();
}
if($count==0)
echo $ids."|".$name;
}
?>
My goal is to get this mod modded to suit my needs, and test it fully to make sure nothing is broken and then package everything together and submit it as an update as I have seen many people asking about being able to have the ability to have 4 drop downs, so if this can be achieved (which it should be able to as I have come to realize that with Zen almost anything is possible) it would be good for other members as well, and future store owners, as almost everything is broken down by year/make/model/engine or year/make/model/sub model. While 3 is generally good enough for certain industries, ones like the one I am in would have 60-70 if not more results per page without further breaking it down, where as if it can be broke down 1 step further that number could be closer to 10-15 and fit nicely on just 1 or 2 pages.
Future plans is to have it to where they can select their vehicle and them not only will it show parts available, but also save a cookie that reminds the site what vehicle type they have and will only show products in the categories applicable to their vehicle, this way the categories do not have to be broke down by vehicle type as well. And then or coarse have a clear button if they wanted to change their type of vehicle.
I am aware that this is going to take a lot of work, I am also aware that their will be a good bit of custom coding involved, but the first step I think is getting this particular contribution to suit the basic needs, and then I can start figuring out how to get the rest to work I am sure that I will have many questions a long the way, however with the great community here I am sure this can be accomplished and once it is uploaded as a contribution to the community :)
Thanks
J
Re: Product Finder: multiple category drop-downs
Normally I don't do any support here as I have never had to understand how it works...but last week I decided to improve this for my own use and have ended up complely re-writing and commenting it so all can understand it.
As part of that I will also add the optional code necessary for a four-deep search.
I'll have a version available for testing shortly, but don't hold your breath so find something else to do in the meantime!
Re: Product Finder: multiple category drop-downs
Sounds good I look forward to it, in the mean time I will keep tinkering with it to see if I can get it functioning, if not when you new contribution becomes available I will check it out and test it for you. If I get the 4th working on my own I will still test it out for you though :)
Thanks
J
Re: Product Finder: multiple category drop-downs
Just an update everyone I now have this working with 4 drop downs, a colleague that we have recently started working with was able to help us out a good amount on this. Was able to clean the code up a good bit, keep it from loading every single category on page load, reduced the amount of calls the script has to do to the database as far as round trips go, and all in all it is working very good, we are using easy populate to upload our spreadsheets now and it is looking very nice. If you would like to reach out to him he could hook you up his site is www.designbyklein.com just shoot him an email and he can send you over the optimized code. You can check out what he was able to help us turn this mod into on our site @ bullys performance dot com, on the left sidebox near the top (might not be there yet at the time of this writing due to cache if it is not it will be soon).
Re: Product Finder: multiple category drop-downs
Quote:
just shoot him an email and he can send you over the optimized code.
I did that and was informed he would not send out modified/paid-for code without your permission.
Note that the modifications you/he has done on your site to provide four drop-downs have broken the no-javascript functionality of this mod.
Note also that this mod only exists because I paid for someone to make it in the first place. I have finished improving it and am only waiting to see your performance improvements before posting a new version.
Re: Product Finder: multiple category drop-downs
Not sure what javascript is broken could you elaborate a little on that as it functions in google chrome and firefox on my linux box just fine, I did not want all 4 boxes to start with, you click the first box and make your selection then the second one populates, and you make another then the 3rd one populates then you select the last box and your products show? So I am not exactly sure what is broken...
Re: Product Finder: multiple category drop-downs
Using 1.5, is there an updated version of this product, it is exactly what I need. Make,Model,Year....
Re: Product Finder: multiple category drop-downs
Quote:
Originally Posted by
jwaynehinkle
Just an update everyone I now have this working with 4 drop downs, a colleague that we have recently started working with was able to help us out a good amount on this. Was able to clean the code up a good bit, keep it from loading every single category on page load, reduced the amount of calls the script has to do to the database as far as round trips go, and all in all it is working very good, we are using easy populate to upload our spreadsheets now and it is looking very nice. If you would like to reach out to him he could hook you up his site is
www.designbyklein.com just shoot him an email and he can send you over the optimized code. You can check out what he was able to help us turn this mod into on our site @ bullys performance dot com, on the left sidebox near the top (might not be there yet at the time of this writing due to cache if it is not it will be soon).
do you know how much he is charging ?
thanks