summaryrefslogtreecommitdiff
path: root/httemplate/search/elements/metasearch.html
blob: b9d3e3ce2e02fe02d63a4ca825a8e2b63f8e8698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<%doc>

Example:

  include( 'elements/metasearch.html',

    ###
    # required
    ###

    'title'         => 'Page title',
    
    #arrayref of hashrefs suited for passing to elements/search.html
    #see that documentation
    'search'      => [
                       {
                         query => { 'table'     => 'tablename',
                                    #everything else is optional...
                                    'hashref'   => { 'f1' => 'value',
                                                     'f2' => { 'op'   => '<',
                                                               'value' => '54',
                                                             },
                                                    },
                                    'select'    => '*',
                                    'order_by'  => 'ORDER BY something',
   
                                  },
                         count_query => 'SELECT COUNT(*) FROM tablename',
                       },
                       {
                         query => 'table'     => 'anothertablename',
                         count_query => 'SELECT COUNT(*) FROM anothertablename',
                       },
                     ],
   
    ###
    # optional
    ###
   
    # some HTML callbacks...
    'menubar'          => '', #menubar arrayref
    'html_init'        => '', #after the header/menubar and before the pager
    'html_form'        => '', #after the pager, right before the results
                              # (only shown if there are results)
                              # (use this for any form-opening tag rather than
                              #  html_init, to avoid a nested form)
    'html_foot'        => '', #at the bottom
    'html_posttotal'   => '', #at the bottom
                              # (these three can be strings or coderefs)
   
  );

</%doc>
% foreach my $search ( @{$opt{search}} ) {
<% include('search.html',
             %$search,
             'type'           => $type,
             'nohtmlheader'   => 1,
          )
%>
%
% } 
<%init>

my(%opt) = @_;
#warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n";

my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|select|html(-print)?)$/
           ? $1 : 'html' ;

</%init>