This is a discussion on Make and Model for auto web sites. within the v3.0 Questions & Support forums, part of the v3.0.x Help & Support category; I know this will be simpler to implement in the next version but if anyone would like to add this ...
|
|||||||
|
|
LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
I know this will be simpler to implement in the next version but if anyone would like to add this in V3.0.14 here is a step by step.
1.Enter administration and create all the car brands (make) as independent categories. 2.Create in extra fields as many model fields as there are makes, each make field is tied to a category (ex:field "Ford Model" in extra fields is linked to field "Ford" in edit categories). 3. Once the database fields are connected, create two dynamic fields in your search page and name them make and model. 4. I used a filterselect javascript to activate the model field, it only displays models for the currently selected make, if no model is selected then it is dormant. Here is the actual code (I put this in search.tpl): <form name="search" id="search" method="get" action="searchresults.php"> <script src="includes/filterSelect.js"></script> <script language="JavaScript"> auto_enable_disable = true; handle_events_on_filter = true; </script> <td align="left" class="formleft" width=50>Make:</td> <td class="formright" width=175><select name="make" onChange="filterSelect(model,this)"> <!-- // Makes // --> <option value="">All Makes</option> <option value="1">Alfa Romeo</option> <option value="2">Audi</option> <option value="3">BMW</option> etc.... </select> </td> *Note that the option value must match the "id" field in the categories table otherwise it will give you wrong results. <td align="left" class="formleft" width=50>Model:</td> <td class="formright" width=175><select name="model" disabled="true"> <option value="" filter="">All Models</option> <!-- // Alfa Romeo Models // --> <option value="GTA" filter="19">GTA</option> <option value="Spider" filter="19">Spider</option> etc... </select> </td> <td class="pformstrip" width=50 align=middle><input type="submit" name="Submit" value="{$smarty.const.LANG_SEARCH_BUTTON}" /> </form> 5. Since we are calling searchresults.php, we must make changes in there so that the right results are displayed. Find and replace this line: if(substr($objItem,0,3)=="opt" && $objValue<>"") with: if($objItem=="model" && $objValue<>"") to find the models Finally replace this line: $sSQL .= ( empty($_REQUEST['type']) ) ? '': " AND p.section LIKE '%".safeAddSlashes($_REQUEST['type'])."%'"; with: $sSQL .= ( empty($_REQUEST['make']) ) ? '': " AND p.section LIKE '%".safeAddSlashes($_REQUEST['make'])."%'"; This will get the right make and you are done. |
|
#2
|
||||
|
||||
|
This is a great mod!
Now if we wanted to add a 'count' to each of the 'models', is this possible and how might we go about it? eg: FORD - Escort(34) - Explorer (2) - Fiesta (23) ...etc
__________________
Chaslie V3.1.10 dev AUSCITY 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals HTML Help W3 Schools |
|
#3
|
||||
|
||||
|
Sorry for the really late reply Chaslie.
Would you like to display something like (category) Make --> (subcategory) Model ? The model in my mod is an extra field not a subcat but I am sure I could create a workaround with sql. |
|
#4
|
||||
|
||||
|
No the way you have yours working and how it is being displayed is fine. Just wondering if a model 'count' can be included or added and displayed like this:
FORD - Escort(34) - Explorer (2) - Fiesta (23) ...etc
__________________
Chaslie V3.1.10 dev AUSCITY 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals HTML Help W3 Schools |
|
#5
|
||||
|
||||
|
Been a bit ofline busy. I will try and find a way to do this some time soon.
|