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

Access search substring in search.php

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-17-2008, 01:34 PM
 
staalejg staalejg is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 63
 

Default 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).
__________________
Juan (Teksavers)
Reply With Quote
  #2  
Old 11-17-2008, 11:52 PM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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']
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #3  
Old 11-18-2008, 02:27 PM
 
staalejg staalejg is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 63
 

Default 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?
__________________
Juan (Teksavers)
Reply With Quote
  #4  
Old 11-19-2008, 03:06 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #5  
Old 11-19-2008, 06:51 AM
 
staalejg staalejg is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 63
 

Default 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.
__________________
Juan (Teksavers)
Reply With Quote
  #6  
Old 11-19-2008, 07:19 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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.
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
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 03:37 PM.

   

 
X-Cart forums © 2001-2020