Akopia Akopia Services

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

Re: [mv] MV4 [query ] with [more] list



Quoting Christian J. M|ller (cmueller@polinet.ch):
> Has anyone figured out how to limit list output from a SQL [query] using
> [more-list]?

I have, but you are right. It doesn't work with SQL queries until you 
apply the attached patch. (I had the problem solved another way at one time,
but I must have lost that work.)

I was working on a catalog this morning and needed the same thing....8-)

Once you apply the patch, you will need to put the iterating region
inside a [list] [/list] pair, along with the [more-list]:

[query list=1 ml=5 more=1 sql="select * from products"]
[list]
[sql-code] [sql-param title]<BR>
[/list]
[more-list]
[more]
[/more-list]
[/query]

The below will work for everything, even without the patch:

[search-region more=1
                search="
                    ra=yes
                    rf=*
                    co=yes
                    sf=category
                    se=Surrealists
                    st=db
                    ml=4
                "]
[search-list]
[item-code] [item-param title]<BR>
[/search-list]
[more-list]
[more]
[/more-list]
[/search-region]

But I must have screwed something up -- I cannot yet figure out why
sq=select * ... doesn't work in search-region.

Mike
-- 
Internet Robotics, 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mikeh@minivend.com>

Light travels faster than sound. This is why some people appear bright
until you hear them speak. -- unknown
diff -xRCS -b -I # *.Id:\|VER.*Revision: -r -c ./Interpolate.pm /rt/Interpolate.pm
*** ./Interpolate.pm	Sun Feb 27 15:54:17 2000
--- /rt/Interpolate.pm	Wed Mar  1 07:08:37 2000
***************
*** 2749,2754 ****
--- 2749,2755 ----
  		$total,
  		$current,
  		$page,
+ 		$prefix,
  		$session,
  		);
  
***************
*** 2757,2762 ****
--- 2758,2765 ----
  	my ($next, $last, $arg);
  	my $list = '';
  	$pa =~ s/__PAGE__/$inc/g;
+ 	my $form_arg = "mv_nextpage=$page";
+ 	$form_arg .= "\npf=$prefix" if $prefix;
  	$next = ($inc-1) * $chunk;
  #::logDebug("more_link: inc=$inc current=$current");
  	$last = $next + $chunk - 1;
***************
*** 2804,2809 ****
--- 2807,2813 ----
  				? $q->{mv_next_pointer}
  				: $first + $chunk;
  	$page = $q->{mv_search_page} || $Global::Variable->{MV_PAGE};
+ 	$prefix = $q->{prefix} || '';
  
  	if($r =~ s:\[border\]($All)\[/border\]::i) {
  		$border = $1;
***************
*** 2848,2854 ****
  			$arg .= ":$chunk";
  			$list .= '<A HREF="';
  			#$list .= vendUrl("scan/MM=$arg/np=$page");
! 			$list .= tag_area( "scan/MM=$arg", '', { form => "mv_nextpage=$page" });
  			$list .= '">';
  			$list .= $prev_anchor;
  			$list .= '</A> ';
--- 2852,2860 ----
  			$arg .= ":$chunk";
  			$list .= '<A HREF="';
  			#$list .= vendUrl("scan/MM=$arg/np=$page");
! 			my $form_arg = "mv_nextpage=$page";
! 			$form_arg .= "\npf=$prefix" if $prefix;
! 			$list .= tag_area( "scan/MM=$arg", '', { form => $form_arg });
  			$list .= '">';
  			$list .= $prev_anchor;
  			$list .= '</A> ';
***************
*** 2874,2883 ****
  		$last = $last > ($total - 1) ? $total - 1 : $last;
  		$arg = "$session:$next:$last:$chunk";
  		$next_tag .= '<A HREF="';
! 		#$next_tag .= vendUrl("scan/MM=$arg/np=$page");
  		$next_tag .= tag_area("scan/MM=$arg");
  		$next_tag .= $next_tag =~ /\?.+=/ ? '&' : '?';
  		$next_tag .= "mv_nextpage=$page";
  		$next_tag .= '">';
  		$next_tag .= $next_anchor;
  		$next_tag .= '</A>';
--- 2880,2890 ----
  		$last = $last > ($total - 1) ? $total - 1 : $last;
  		$arg = "$session:$next:$last:$chunk";
  		$next_tag .= '<A HREF="';
! 		#$next_tag .= vendUrl("scan/MM=$arg$pfu/np=$page");
  		$next_tag .= tag_area("scan/MM=$arg");
  		$next_tag .= $next_tag =~ /\?.+=/ ? '&' : '?';
  		$next_tag .= "mv_nextpage=$page";
+ 		$next_tag .= "&pf=$prefix" if $prefix;
  		$next_tag .= '">';
  		$next_tag .= $next_anchor;
  		$next_tag .= '</A>';
***************
*** 3557,3562 ****
--- 3564,3583 ----
  	my $prefix = defined $opt->{list_prefix} ? $opt->{list_prefix} : 'list';
  
  #::logDebug("region: opt:\n" . ::uneval($opt) . "\npage:" . substr($page,0,100));
+ 
+ 	if($opt->{ml} and ! defined $obj->{mv_matchlimit}) {
+ 		$obj->{mv_matchlimit} = $opt->{ml};
+ 		$obj->{matches} = scalar @{$obj->{mv_results}};
+ 		$obj->{mv_cache_key} = generate_key(substr($page,0,100));
+ 		$obj->{mv_first_match} = $opt->{fm} if $opt->{fm};
+ 		$obj->{mv_search_page} = $opt->{sp} if $opt->{sp};
+ 		$obj->{prefix} = $opt->{prefix} if $opt->{prefix};
+ 		my $out = delete $obj->{mv_results};
+ 		Vend::Search::save_more($obj, $out);
+ 		$obj->{mv_results} = $out;
+ 	}
+ 
+ 	$opt->{prefix} = $obj->{prefix} if $obj->{prefix};
  
  	$page =~ s!$QR{more_list}! tag_more_list($1,$2,$3,$4,$5,$opt,$6)!ge;
  	$page =~ s!$QR{no_match}!
diff -xRCS -b -I # *.Id:\|VER.*Revision: -r -c ./Scan.pm /rt/Scan.pm
*** ./Scan.pm	Sun Feb 27 15:54:30 2000
--- /rt/Scan.pm	Wed Mar  1 07:04:39 2000
***************
*** 93,98 ****
--- 93,99 ----
  					mv_unique
  					mv_more_matches
  					mv_value
+ 					prefix
  
  ));
  
***************
*** 135,140 ****
--- 136,142 ----
                      nu  mv_numeric
                      op  mv_column_op
                      os  mv_orsearch
+ 					pf  prefix
                      ra  mv_return_all
                      rd  mv_return_delim
                      rf  mv_return_fields
diff -xRCS -b -I # *.Id:\|VER.*Revision: -r -c ./Table/DBI.pm /rt/Table/DBI.pm
*** ./Table/DBI.pm	Sun Feb 27 15:54:47 2000
--- /rt/Table/DBI.pm	Wed Mar  1 05:48:53 2000
***************
*** 815,821 ****
  #::logDebug("finished query, rc=$rc ref=$ref arrayref=$opt->{arrayref} Tmp=$Vend::Interpolate::Tmp->{$opt->{arrayref}}");
  	return $rc
  		if $opt->{row_count};
! 	return Vend::Interpolate::tag_sql_list($text, $ref, \%nh)
  		if $opt->{list};
  	return Vend::Interpolate::html_table($opt, $ref, \@na)
  		if $opt->{html};
--- 815,821 ----
  #::logDebug("finished query, rc=$rc ref=$ref arrayref=$opt->{arrayref} Tmp=$Vend::Interpolate::Tmp->{$opt->{arrayref}}");
  	return $rc
  		if $opt->{row_count};
! 	return Vend::Interpolate::tag_sql_list($text, $ref, \%nh, $opt)
  		if $opt->{list};
  	return Vend::Interpolate::html_table($opt, $ref, \@na)
  		if $opt->{html};

Search for: Match: Format: Sort by: