[interchange-cvs] interchange - heins modified lib/Vend/RefSearch.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Thu Jul 22 22:48:58 EDT 2004
User: heins
Date: 2004-07-23 02:48:58 GMT
Modified: lib/Vend RefSearch.pm
Log:
* Make filtering previous searches easier.
Before this, you had to create your own reference and somehow
pass it to the search object, and you had to provide your own
field names.
This patch assumes that if the called reference (re=foo) is
a scalar, it refers to $::Instance->{SearchObject}, which will
have the results of the last search.
So you can now do:
[loop
label=foo
search="
sf=prod_group
se=Hand Tools
rf=*
"
/]
<p>
Searching the reference...
</p>
[loop
search="
st=ref
re=foo
co=yes
sf=category
se=Shears
rf=*
"
]
[loop-param sku]<br>
<blockquote>
-- prod_group=[loop-param prod_group]<br>
-- cat=[loop-param category]<br>
-- description=[loop-param description] <br><br>
</blockquote>
[/loop]
I don't quite know why I didn't do this before -- probably I had completed
what I wanted to do and never set it up to be used generally.
TODO: Make it work for queries as a source, too.
Revision Changes Path
2.7 +14 -2 interchange/lib/Vend/RefSearch.pm
rev 2.7, prev_rev 2.6
Index: RefSearch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/RefSearch.pm,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- RefSearch.pm 18 Jun 2003 17:34:44 -0000 2.6
+++ RefSearch.pm 23 Jul 2004 02:48:58 -0000 2.7
@@ -1,6 +1,6 @@
# Vend::DbSearch - Search indexes with Interchange
#
-# $Id: RefSearch.pm,v 2.6 2003/06/18 17:34:44 jon Exp $
+# $Id: RefSearch.pm,v 2.7 2004/07/23 02:48:58 mheins Exp $
#
# Adapted for use with Interchange from Search::TextSearch
#
@@ -27,7 +27,7 @@
@ISA = qw(Vend::Search);
-$VERSION = substr(q$Revision: 2.6 $, 10);
+$VERSION = substr(q$Revision: 2.7 $, 10);
use strict;
@@ -159,6 +159,18 @@
my $target = $s->{mv_search_reference};
#::logDebug("target: " . ::uneval($target));
+ if(! ref $target) {
+ my $label = $target;
+ my $sr = $::Instance->{SearchObject}{$label};
+ if(! $sr) {
+ return $s->search_error("$label is not a target nor a label referencing a previous search");
+ }
+ $target= $sr->{mv_results};
+ $s->{mv_field_names} ||= $sr->{mv_field_names};
+ }
+
+#::logDebug("field names=" . ::uneval($s->{mv_field_names}));
+#::logDebug("target now: " . ::uneval($target));
if(
ref($target) ne 'ARRAY'
or
More information about the interchange-cvs
mailing list