The Imperial CMS provides a powerful search result call, and you can create most of the search functionality that meets your needs by making the grammar from the Imperial CMS search form. If you have custom fields in your database, you may need to change the data processing that e/search/index.php submits to form forms, and refer to the examples provided at the end of the article. Let's take a look at the search form variable description:
Variable Name Description Example search Form Submit address Post method:/e/search/index.php<form name= "Searchform" method= "post" action= "/e/search/index.php" >get Way:/e/search/?searchget=1/e/search/?searchget=1&keyboard= Empire &show=titlekeyboard search keyword variable <input Name= "Keyboard" type= "text" >show the search field variable (multiple fields are opened with "," lattice.) The search field must be a background model to open the search field) <input type= "hidden" name= "show" value= "Title,newstext" >CLASSID search column ID (not set to unlimited, multiple columns available "," the grid Open , set the parent column will search all the sub columns) <input type= "hidden" name= "ClassID" value= "1" >ztid search topic ID (not set to unlimited, multiple topics available "," lattice Open) <input type= " Hidden "name=" Ztid value= "1" >tbname by data table search (with search template id) <input type= "hidden" name= "Tbname" value= "News" > Tempid Search Template ID (commonly used in conjunction with table search) <input type= "hidden" name= "Tempid" value= "1" > StartTime and Endtime, respectively, are the information for the start and end time of the search publication (not limited to. Format: 2008-02-27) <input name= "StartTime" type= "text" value= "0000-00-00" size= ">"
<input name= "Endtime" type= "text" value= "0000-00-00" size= "a" >startprice and Endprice are respectively the starting price and the end price of the commodity price (not to be filled in) <input name= "StartPrice" type= "text" value= "0" size= "6" >
<input name= "Endprice" type= "text" value= "0" size= "6" > Search Special Field ID: Search by Information ID
Keyboard: By keyword search (can be achieved by tags listed information)
UserID: Search by publisher User ID
Username: Search by publisher username <input type= "hidden" name= "show" value= "Keyboard" >member value is 0 without restriction
A value of 1 will only search for information on member submissions
A value of 2 is a search for administrator-added information <input type= "hidden" name= "Member" value= "1" >orderby sort fields:
0: By Release date (default)
1: By ID
2: By the number of comments
3: Press Browse popularity
4: By download number <input type= "hidden" name= "Order By" value= "1" >myorder Sort by:
0: Reverse order (default)
1: Sequential <input type= "hidden" name= "Myorder" value= "1" >andor set up the relationship between multiple criteria query, there are two kinds:
Or: or a relationship (default)
And: And the relationship <input type= "hidden" name= "Andor" value= "and" >hh logical operator variables:
LT: Less than
GT: Greater Than
EQ: Equal To
LE: less than or equal
GE: greater than or equal
NE: Not equal to
In: include (search for keywords separated by spaces for each value)
BT: Range, between two values (search keywords separated by a space of two values)
LK: Fuzzy query (default) <input type= "hidden" name= "hh" value= "LK" >
Here is an example:
<tablewidth= "border=" "0" cellspacing= "1" cellpadding= "3" >
<formname= "Searchform" method= "post" action= "/e/search/index.php" >
<tr>
<td> keywords: <inputname= "keyboard" type= "text" size= "ten" ></td>
<td> Scope:
<selectname= "Show" >
<optionvalue= "title" > title </option>
<optionvalue= "Smalltext" > Profile </option>
<optionvalue= "Newstext" > Content </option>
<optionvalue= "Writer" > Author </option>
<optionvalue= "Title,smalltext,newstext,writer" > Search all </option>
</select></td>
</tr>
<tr>
<td> columns:
<selectname= "ClassID" >
<optionvalue= "0" > Search all </option>
<optionvalue= "1" > News Center </option>
<optionvalue= "4" > Technical documents </option>
<optionvalue= > Download Center </option>
</select> </td>
<td><inputtype= "Submit" name= "submit" value= "Search" ></td>
</tr>
</form>
</table>
Search form multiple conditions parallel search Syntax description
1. Multi-field Parallel search: There are "string" and "array" two ways of transmission
String passing as an example:
<inputtype= "hidden" name= "hh" value= "LK" >
<inputtype= "hidden" name= "show" value= "Title,writer" >
<inputtype= "hidden" name= "keyboard" value= "title, author" >
Description: The above for the Fuzzy query title field contains "title" character or writer field contains "author" information
The array is passed as an example:
<inputtype= "hidden" name= "hh" value= "LK" >
<inputtype= "hidden" name= "show[]" value= "title" >
<inputtype= "hidden" name= "keyboard[]" value= "title" >
<inputtype= "hidden" name= "show[]" value= "writer" >
<inputtype= "hidden" name= "keyboard[]" value= "Author" >
The above for the Fuzzy Query title field contains the title character or the writer field contains information about "author"
2. Multi-logical operation coupling and parallel search
String passing as an example:
<inputtype= "hidden" name= "hh" value= "Lk,eq" >
<inputtype= "hidden" name= "show" value= "Title,writer" >
<inputtype= "hidden" name= "keyboard" value= "title, author" >
Description: The above for the Fuzzy query title field contains "title" character or writer field equals "author" information
String passing as an example:
<inputtype= "hidden" name= "show[]" value= "title" >
<inputtype= "hidden" name= "hh[]" value= "LK" >
<inputtype= "hidden" name= "keyboard[]" value= "title" >
<inputtype= "hidden" name= "show[]" value= "writer" >
<inputtype= "hidden" name= "hh[]" value= "EQ" >
<inputtype= "hidden" name= "keyboard[]" value= "Author" >
Description: The above for the Fuzzy Query title field contains the "title" character or the writer field equals "author" information.
A practical example
The form is designed as follows:
<formaction= "[!--news.url--]e/search/index.php" method= "post" name= "Searchform" id= "Searchform" >
<selectname= "ClassID" id= "" style= "Display:none" >
<optionvalue= "59,60,78,79,80,81" selected> all </option>
</select>
<inputtype= "hidden" name= "show" value= "Title,myarea,mycategory,smalltext"/>
<inputtype= "hidden" name= "Tempid" value= "1"/>
<tablewidth= "100%" cellspacing= "0" cellpadding= "0" border= "0" >
<tbody>
<trclass= "even" >
<tdstyle= "Text-align:left;" > Area:
<selectname= "area" id= "" >
<optionvalue= "" > No Limit </option>
<optionvalue= "Xiangzhou" > Xiangzhou </option>
<optionvalue= "Jida" > Jida </option>
<optionvalue= "Arch North" > Arch North </option>
<optionvalue= "Xinxiangzhou" > Xinxiangzhou </option>
<optionvalue= "Qian Shan" > Qian shan </option>
<optionvalue= "South Screen" > South screen </option>
<optionvalue= "King Bay" > King Bay </option>
<optionvalue= "Doumen" > Doumen </option>
</select>
Room Type:
<selectname= "category" Id= "" >
<optionvalue= "" > No Limit </option>
<optionvalue= "58_0" > One room </option>
<optionvalue= "58_1" > Sequel </option>
<optionvalue= "58_2" > more than three rooms </option>
<optionvalue= "58_3" > Apartments </option>
<optionvalue= "58_4" > Office </option>
<optionvalue= "58_5" > Shop </option>
<optionvalue= "58_6" > Workshop </option>
</select>
</td>
<td> </td>
</tr>
<trclass= "even" >
<tdstyle= "Text-align:left;" > Time range: <inputname= "StartTime" type= "text" value= "2008-08-08" size= "onclick=" calendar.show (this); " /> to <inputtype= "text" id= "Todaybutton" name= "Todaybutton" value= "" size= "" onclick= "calendar.show (this); /> (optional time limit) </td>
<td> </td>
</tr>
<trclass= "even" >
<tdstyle= "Text-align:left;" ><inputname= "Keyboard" type= "text" size= "value=" "id=" keyboard "class=" Inputtext "/> <inputtype=" Submit "Name=" Submit22 "value=" Search "/></td>
<td></td>
</tr>
</tbody>
</table>
</form>
In order to be able to add a search for custom fields Myarea and mycategory, we need to rewrite the e/search/index.php appropriately:
$keyboard =$_post[' keyboard ']. ', '. $_post[' area '. '. $_post[' category '];
This is the original: $keyboard =$_post[' keyboard '];
$keyboardone = 0;
if (Is_array ($keyboard))
{}
ElseIf (Strstr ($keyboard, ', '))
{
$keyboard =explode (', ', $keyboard);
}
Else
{
$keyboard =trim ($keyboard);
$len =strlen ($keyboard);
if ($len < $public _r[min_keyboard] $len > $public _r[max_keyboard])
{
Printerror ("Minkeyboard", $getfrom, 1);
}
$keyboardone = 1;
}