Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Drop down menu

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-20-2004, 12:07 PM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default Drop down menu

I need some help with a drop down menu I am trying to pull from the database.

What I am trying to do is generate a pull down menu from the brand field in the database based on if the categoryid on that same row as the brand matches the category currently being browsed.

Here is my select tag

Code:
<select name=brands> {section name=brands loop=$brand_query} <option {if $products[product].brand eq $brand_query[brands]}selected{/if}>{$brand_query[brands]}</option> {/section} </select>

Hee is my php

Code:
function brand_query() { $brand_query = "select $sql_tbl[products].brand where $sql_tbl[products].categoryid = $cat"; } $smarty->assign("main","specific_search.tpl") ?>


If someone could please make some suggestions or give me a push in the right direction it would be much appreciated.

I am going to keep working on it, and reading my php book.


Thanks.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #2  
Old 01-20-2004, 04:18 PM
 
laureon laureon is offline
 

Senior Member
  
Join Date: Oct 2003
Posts: 171
 

Default

take a look at one of my posts:

http://forum.x-cart.com/viewtopic.php?p=35218#35218

hope it helps you!
__________________
X-Cart Gold Version: 4.0.17
X-Configurator
X-AOM
X-FancyCategories
X-RMA
X-Offers
Reply With Quote
  #3  
Old 01-21-2004, 07:52 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

thank you for your reply. I put in your code but still same with not result on the drop down. Only thing that pops up is result.

At the bottom of your post you mention the serach.php needs to be altered, how do you mean? I put the query in the serach.php but is there something else that needs to be altered that I am missing?
I read through that topic too and tried a bunch of things but all came to the same result of no drop down being filled with the brand.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #4  
Old 01-21-2004, 11:58 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

OK I got the drop downs to generate finally and now I have a simple question that I cannot find the answer too.

IF I put the select tags on the advanced_search.tpl they generate fine. If I put the same tags on my custom specific_search.tpl they do not generate. It is using the same form tag so it should be calling to the same php file right? What I am guessing is there is a file somewhere that I did not active the tpl or maybe php file.

Here is my customer/specific_search.php:

Code:
<?php # # $Id: search.php,v 1.50 2003/11/12 14:42:07 svowl Exp $ # # # BRAND query # $brand_query = "SELECT distinct brand FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY brand"; # # model query # $model_query = "SELECT distinct b_model FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY b_model"; // assign query to smarty. $brand = func_query($brand_query); $model = func_query($model_query); $smarty->assign("brand",$brand); $smarty->assign("model",$model); $smarty->assign("main","specific_search"); $smarty->display("customer/home.tpl"); ?>



Here is my skin1/customer/main/specific_search.tpl:

Code:
{* $Id: specfic_search.tpl,v 1.19 2003/04/15 06:23:26 svowl Exp $ *} <table width="100%" border="0" cellspacing="2"> <form action="specific_search.php" name="specificsearch"> <tr valign="top"> <td height="40" colspan="6" align="left" valign="middle"><font class="CategoriesList" color="#FF6600">Specific Search:</font> <hr size=1 noshade width="100%" align="left"></td> </tr> <tr> <td width="12" height="45" valign="top"></td> <td width="212" align="center" valign="top" ><font class="SectionBody">Make:</font> <select onChange="javascript:document.specificsearch.submit()" name="brand"> <option value="">All</option> {section name="brand" loop=$brand} <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option> {/section} </select> </td> <td width="123" align="center" valign="top" > <font class="SectionBody">Model:</font> <select onChange="javascript:document.specificsearch.submit()" name="brand"> <option value="">All</option> {section name="brand" loop=$brand} <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option> {/section} </select> </td> <td width="93" align="center" valign="top" > <font class="SectionBody">Year:</font> <select onChange="javascript:document.specificsearch.submit()" name="brand"> <option value="">All</option> {section name="brand" loop=$brand} <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option> {/section} </select> </td> <td width="88" valign="top"></td> <td width="342" valign="center"><a href="javascript:specificsearch.submit()">{include file="buttons/search.tpl" style="button" type="input"}</a></td> </tr> </form> <tr> <td height="21" colspan="6" valign="top"><hr size=1 noshade></td> <tr> <td height="2"></td> <td ></td> <td ></td> <td ></td> <td></td> <td></td> </table>


I think its a matter of linking the tpl to the php but I cannot see the problem.

Also I did name specific_search.tpl in the home_main.tpl.

Like I said I know the code works but I think the linking is bad and I cannot find where.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #5  
Old 01-21-2004, 09:30 PM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

If someone could please post it would help me out alot.

Thanks.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:17 AM.

   

 
X-Cart forums © 2001-2020