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)
-   -   Access search substring in search.php (https://forum.x-cart.com/showthread.php?t=43730)

staalejg 11-17-2008 01:34 PM

Access search substring in search.php
 
I want to run an external process as part of search.php when a customer types in a search term. Can someone tell me which variable has the substring that is entered in the search form (x-cart 4.1.9).

Victor D 11-17-2008 11:52 PM

Re: Access search substring in search.php
 
There is array $posted_data that is cleaned out according to the array
$allowable_search_fields set in search.php:
PHP Code:

$allowable_search_fields = array (
    
"substring",
    
"by_title",
    
"by_shortdescr",
    
"by_fulldescr",
    
"by_sku",
    
"extra_fields",
    
"by_keywords",
    
"categoryid",
    
"category_main",
    
"category_extra",
    
"search_in_subcategories",
    
"price_max",
    
"price_min",
    
"price_max",
    
"avail_min",
    
"avail_max",
    
"weight_min",
    
"weight_max",
    
"manufacturers"); 

So you can refer it as $posted_data['substring']

staalejg 11-18-2008 02:27 PM

Re: Access search substring in search.php
 
I added the following to xcartdir/search.php just to see if this was the correct variable.

$searchterm = $posted_data["substring"];
echo "$searchterm";

echo returns blank data which leads me to believe this is the wrong variable?

Victor D 11-19-2008 03:06 AM

Re: Access search substring in search.php
 
I've placed
PHP Code:

$searchterm $posted_data["substring"];
die (
$searchterm); 


in search.php after the line
PHP Code:

x_session_register("search_data"); 


and it works

staalejg 11-19-2008 06:51 AM

Re: Access search substring in search.php
 
Cool. So echo must not work at that point in the script. die ($searchterm) worked for me too.

Thanks.

Victor D 11-19-2008 07:19 AM

Re: Access search substring in search.php
 
It is not for sure but I suspect the page to redirect after search form submitting so its content is refreshing after echo.


All times are GMT -8. The time now is 01:34 AM.

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