default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / search / elements / metasearch.html
1 <%doc>
2
3 Example:
4
5   include( 'elements/metasearch.html',
6
7     ###
8     # required
9     ###
10
11     'title'         => 'Page title',
12     
13     #arrayref of hashrefs suited for passing to elements/search.html
14     #see that documentation
15     'search'      => [
16                        {
17                          query => { 'table'     => 'tablename',
18                                     #everything else is optional...
19                                     'hashref'   => { 'f1' => 'value',
20                                                      'f2' => { 'op'   => '<',
21                                                                'value' => '54',
22                                                              },
23                                                     },
24                                     'select'    => '*',
25                                     'order_by'  => 'ORDER BY something',
26    
27                                   },
28                          count_query => 'SELECT COUNT(*) FROM tablename',
29                        },
30                        {
31                          query => 'table'     => 'anothertablename',
32                          count_query => 'SELECT COUNT(*) FROM anothertablename',
33                        },
34                      ],
35    
36     ###
37     # optional
38     ###
39    
40     # some HTML callbacks...
41     'menubar'          => '', #menubar arrayref
42     'html_init'        => '', #after the header/menubar and before the pager
43     'html_form'        => '', #after the pager, right before the results
44                               # (only shown if there are results)
45                               # (use this for any form-opening tag rather than
46                               #  html_init, to avoid a nested form)
47     'html_foot'        => '', #at the bottom
48     'html_posttotal'   => '', #at the bottom
49                               # (these three can be strings or coderefs)
50    
51   );
52
53 </%doc>
54 % foreach my $search ( @{$opt{search}} ) {
55 <% include('search.html',
56              %$search,
57              'type'           => $type,
58              'nohtmlheader'   => 1,
59           )
60 %>
61 %
62 % } 
63 <%init>
64
65 my(%opt) = @_;
66 #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n";
67
68 my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|select|html(-print)?)$/
69            ? $1 : 'html' ;
70
71 </%init>