Auggnet
Veteran developer
Profile
Posts: 225
Reg: Nov 20, 2012
USA
2,550
03/19/13 06:38 AM (12 years ago)

BTM Search Plugin (Search Code Edit Help)

Currently the search will only start at the beginning. For example, if i have an item called "item 001" and searched the query "001" it would not find it because it is looking at the beginning. Using the same example but with the query "tem" would find the "tem" in "Item 001" Additionally i would like even 1 letter searches, for example if i enter the query "e" item 001 would still pop up. Do you see what i mean? I got the code from the BTM Search menu on the for loop where it searches the imputed string. (Didn't copy all to prevent piracy) Please help me edit! Thanks //search on every character... if([searchBox.text length] > 0){ //loop through items in menu data... for(int i = 0; i < [self.menuItems count]; i++){ BT_item *thisItem = [self.menuItems objectAtIndex:i]; NSRange r = [[thisItem.jsonVars objectForKey:@"titleText"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; if(r.location != NSNotFound){ if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; } } } } Thankyou all!
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
03/19/13 08:08 AM (12 years ago)
This is a post from David about a year ago regarding the initial v1.5 search plugin but works for BTM search plugin as well: ------------------------------------------------------------ b) Searching today is simple, 'find content that starts with' the entered character. This could easily be changed to use 'contains' instead of 'starts with'. In fact, this should probably be an option in the control panel. Changing this on your end will take :90 seconds. Look for... if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; } and get rid of the if(r.location == 0) condition. Just comment this out like: //if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; //} ------------------------------ hope that helps, josh
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/24/13 07:23 PM (12 years ago)
Thanks Josh, I submitted a update for this to buzztouch, with credits to you and david in the comments under the code fix in .m Cheers, David https://buzztouchmods.com
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.