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
/**
* 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
<!-- 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
/**
* 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
/** 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