Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Loop-Next Type Tag in [search-list] container



******    message to minivend-users from Ed LaFrance <edl@newmediaems.com>     ******

Hi Cory -

I recently wrote a half-arsed patch to TextSearch.pm in Minivend 3.14-6 to 
do something similar, maybe your could adapt it (and I think just about any 
one could improve it :-).  The idea behind the patch was to compare a 
product-related field value against a filter string that might contain one 
value or many; if the former is found in the latter, then the item is 
removed from the array which contains the search results.  Since this all 
pre item-list, item-increment, paging, etc still work correctly and no 
special logic is required in a results page.

To use this, you need to put your filter string in a variable (let's say 
[value filter_string]), and set mv_return_fields to contain the key field 
('code' for a typical products file) and the name of the field to be 
compared against the filter_string.

Add this patch to TextSearch.pm (and I think it would in DBSearch with a 
little tweaking) around line 380, after all other search manipulations and 
before $g->{matches} is assigned (I am showing this in the context of some 
existing code before and after):

         if($delayed_return) {
                 $s->sort_search_return(\@out);
                 @out = map { &{$delayed_return}($_) } @out;
         }

         if($g->{unique_result}) {
                 my %seen;
                 @out = grep ! $seen{$_}++, @out;
         }

         #PATCH STARTS HERE ----------->

         my $filter_string = $::Values->{filter_string};
         if ($filter_string) {
                 my $foundcount = 0;
                 my $one;
                 my @out_temp;
                 foreach (@out) {
                         $one = $_;
                         $one =~ s/\w.*\t//;
                         unless ((index($filter_string, $one) + 1)) {
                                 $out_temp[$foundcount] = $_;
                                 ++$foundcount;

                         }
                 }
                 @out = @out_temp;
         }

         #----------------> END OF PATCH

    $g->{matches} = scalar(@out);


...Don't forget to set filter_string to an empty value if you don't want to 
use the filter at other points in the session, or you will be scratching 
your head, wondering why records are mysteriously absent from your search 
results.

This is usually where Mike H. pipes in and shows us some slick way we could 
have done this with existing tags and code...but where's the challenge it that?

- Ed L.


At 04:16 PM 10/21/00 -0400, you wrote:
>******    message to minivend-users from Cory Trese 
><digital@frognet.net>     ******
>
>Dearest List --
>
>I have a page where I need to be both able to limit a search based on a
>field in the database (I've had no luck with co-ord searches...) as well
>as make use of the [more] tags to limit the display to 50 matches.
>
>Currently, I'm using a [loop search="...] tag to do an inline search and
>then using the [loop-next] container tag to test a field in a database
>to see if the record should be displayed.  This works fine, for now, but
>soon much more data will be added.
>
>If anyone has an idea on how I can achieve this using a standard results
>page (by adding a loop-next type tage to the [search-list] region on my
>results page, which would replace the page containing the [loop search]
>stuff.)
>
>If you can help me, a CC: digital@frognet.net, would be really nice.
>
>Thanks in advance for any reply,
>Cory Trese
>
>ps : I guess that if it were possible to use a [more] construct like tag
>(1 2 3 4 5 Next ...  sorta thing within a loop search, that would also
>work :)
>-
>To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
>email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
>Archive of past messages: http://www.minivend.com/minivend/minivend-list

 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          edl@newmediaems.com
Placerville, CA  95667         http://www.newmediaems.com
(530) 622-9421                 (530) 622-9426 fax
(866) 519-4680 Toll-Free
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: