X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Multiple search forms (https://forum.x-cart.com/showthread.php?t=7829)

longhorn180 05-29-2004 03:45 PM

Multiple search forms
 
Hopefully someone can help me with this. I'm sure I did this the wrong way, but given my somewhat limited knowledge(zero), I'm not sure how else to do it. I sell books online I am now able to search for books by author, title, isbn or subject with just the 1 search box, but I want 4 seperate search forms or boxes with dedicated fields. I created a template where I copied and pasted the code to create 4 boxes and it works, but there is a caveat. When the results are displayed it also displays whatever you search for in all 4 of the boxes. Ex: if you enter Stephen King into the author box, then when the results are displayed it now says Stephen King in all 4 search boxes. Not a huge problem, but it looks ugly. Any suggestions would be greatly appreciated. I'm using 3.4.14

BCSE 05-29-2004 04:38 PM

Can you post the code? That would really help. I have an idea but would be easy to confirm if I saw the code.

Carrie

longhorn180 05-29-2004 04:59 PM

Here's the code from the template for the search boxes.


Code:

<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%"> 
{$lng.lbl_books}
<tr>
<tr>
</tr>
 <td colspan=2></td>
</tr>
<form method="get" action="../customer/search.php" name=productsearchform>
<tr>
  <td valign="middle"  width=250>
 <input type="text" name="substring" size="16" value="{$smarty.get.substring|escape}">
  </td>
</tr>
<tr>
  <td>{$lng.lbl_author}</td>
</tr>
</form>
</TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%"> 
<tr>
<tr>
</tr>
 <td colspan=2></td>
</tr>
<form method="get" action="../customer/search.php" name=productsearchform>
<tr>
  <td valign="middle"  width=250>
 <input type="text" name="substring" size="16" value="{$smarty.get.substring|escape}">
  </td>
</tr>
<tr>
  <td>{$lng.lbl_title}</td>
</tr>
</form>
</TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%"> 
<tr>
<tr>
</tr>
 <td colspan=2></td>
</tr>
<form method="get" action="../customer/search.php" name=productsearchform>
<tr>
  <td valign="middle"  width=250>
 <input type="text" name="substring" size="16" value="{$smarty.get.substring|escape}">
  </td>
</tr>
<tr>
  <td>{$lng.lbl_isbn}</td>
</tr>
</form>
</TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%"> 
<tr>
<tr>
</tr>
 <td colspan=2></td>
</tr>
<form method="get" action="../customer/search.php" name=productsearchform>
<tr>
  <td valign="middle"  width=250>
 <input type="text" name="substring" size="16" value="{$smarty.get.substring|escape}">
  {include file="buttons/search_head.tpl"}</td>
</tr>
<tr>
  <td>{$lng.lbl_subject}


 

{$lng.lbl_advanced_search}
</td>
</tr>
</form>
</TABLE>



And here's the code from the search.php file (that I got from another thread) for the different search fields:


Code:

// LOOK HERE
// new bit to split search string into separate words
  $con = ""; $substr = "";
  $and="AND";

  if(!empty($substring)){
      $ss = split(" ",$substring);
      foreach($ss as $s)
          // nfc - we add support for other fields to search
        $con[] = "(".$sql_tbl[products].".param08 like '%".$s."%'"." OR ".
                  $sql_tbl[products].".param04 like '%".$s."%'"." OR ".
                  $sql_tbl[products].".product like '%".$s."%'"." OR ".
                  $sql_tbl[products].".param06 like '%".$s."%'"." OR ".
                  $sql_tbl[products].".param00 like '%".$s."%'".")";
        //$substr .= "&substring=".urlencode($substring);
  }
   
  if(empty($and))$and = "OR";
    $substring_query = (!empty($con)) ? " AND (".join(" ".$and." ",$con).") " :" "; //deleted 1

// end of new bit


BCSE 05-29-2004 05:23 PM

This line in each of the <input> tags is what is making the same text show up in each of the inputs.

Quote:

value="{$smarty.get.substring|escape}"

You can remove this completely from all 4 as it's not necessary, but just a convenience. Or just leave it in 1 of them, although that doesn't really make sense either.

If you had a different "name" for each of the <input> tags, then you could use this feature and just change it to be
Quote:

value="{$smarty.get.name1|escape}"
value="{$smarty.get.name2|escape}"
value="{$smarty.get.name3|escape}"
value="{$smarty.get.name4|escape}"


to have it populate each of the text boxes with the previous values. If you wanted it to do it like this, you'd have to change the php code to reflect these changes.

Hope that wasn't too much information or too confusing. The simplest way to fix it is to remove
Quote:

value="{$smarty.get.substring|escape}"
from each of the 4 input tags.

Hope that helps.

Carrie

longhorn180 05-29-2004 05:39 PM

That worked great! Thank you very, very much - really appreciate the assistance.

BCSE 05-29-2004 05:41 PM

Not a problem! :D

Carrie


All times are GMT -8. The time now is 06:08 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.