[ic] SQL + search_region

Jamie Neil jamie at versado.net
Wed May 26 12:21:35 EDT 2004

Jamie Neil wrote:

> Mike Heins wrote:
>> Sounds like mostly you want to pre-do the search with SQL, and
>> then display it with the search-region. This can easily be done
> That's exactly what I want to do. That way I can use a single search 
> results template and code the searches as action maps (somehow feels 
> neater than putting the sql in the pages).
>> by formatting a $Search->{labelname} object, then passing it
>> on with [search-region label=labelname]. I believe you want
>> to have at least:
>>     my $ary = [ [ 'return1', 'return2', ] ];
>>     my $n = scalar @$ary;
>>     $Search->{$label} = {
>>         matches => $n,
>>         mv_results => $ary,
>>         mv_matchlimit => 20,
>>         mv_field_names => [ 'field1', 'field2', ],
>>     };
> Hmm - I'm a bit fuzzy on arrayrefs and hashrefs. Could you give an 
> simple example using the query tag, or is it as simple as just 
> substituting $ary for a query tag and plugging the return field names 
> into the array at the bottom?

OK, I've got it to work this far:

[query arrayref=results sql=|SELECT sku,description FROM products|][/query]
[tmp count]
my $results = $Tmp->{results};
my $count = scalar @$results;
$Search->{results} = {
   matches => $count,
   mv_results => $results,
   mv_matchlimit => 10,
   mv_field_names => [ 'sku', 'description', ],

Results [matches] of [match-count]

[search-region label=results]
<p>[item-code] - [item-param description]</p>

However the more list has a blank reference to the search results:


Maybe I'm going about this all wrong. What I want to achieve is a single 
template that I can use for displaying IC or SQL search results, so that 
if I need to change the layout I need only edit one file.

Should I just resign myself to having more than one template - one for 
IC search and one for SQL?

Jamie Neil | <jamie at versado.net> | 0870 7777 454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254

More information about the interchange-users mailing list